From patchwork Wed Feb 5 18:21:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1233968 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48CVJs3cZJz9sSn for ; Thu, 6 Feb 2020 05:22:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48CVJr21dxzDqM5 for ; Thu, 6 Feb 2020 05:22:04 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=kaod.org (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=groug@kaod.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48CVJV0dshzDqLD for ; Thu, 6 Feb 2020 05:21:45 +1100 (AEDT) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 015IL1Xs073859 for ; Wed, 5 Feb 2020 13:21:43 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xyhn32wdr-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 05 Feb 2020 13:21:43 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Feb 2020 18:21:41 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 5 Feb 2020 18:21:38 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 015ILbI246989544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Feb 2020 18:21:37 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A319B4203F; Wed, 5 Feb 2020 18:21:37 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A2C942042; Wed, 5 Feb 2020 18:21:37 +0000 (GMT) Received: from bahia.lan (unknown [9.145.71.236]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 5 Feb 2020 18:21:37 +0000 (GMT) From: Greg Kurz To: Alexey Kardashevskiy Date: Wed, 05 Feb 2020 19:21:37 +0100 In-Reply-To: <158092689078.2344237.6072760291677054493.stgit@bahia.lan> References: <158092689078.2344237.6072760291677054493.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20020518-0028-0000-0000-000003D7B979 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20020518-0029-0000-0000-0000249C18FA Message-Id: <158092689674.2344237.11169297873757766796.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-05_05:2020-02-04, 2020-02-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 suspectscore=18 phishscore=0 clxscore=1034 adultscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002050140 Subject: [SLOF] [PATCH 1/3] fdt: Fix creating new nodes at H_CAS X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: slof@lists.ozlabs.org Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" From: Alexey Kardashevskiy So far we only allowed new ibm,dynamic-reconfiguration-memory and memory nodes in the FDT update blob at ibm,client-architecture-support (CAS). DRC do not have unit addresses and are easy, for memory nodes we use an address from the node name. For early hot plugged PCI devices (plugged after reset but before CAS) we have to have a similar hack as for memory@ but parse the address differently because of different binding. Instead, this changes new nodes creation. At pass#0 when we copy phandles from the FDT update blob to SLOF, we create new nodes with all new properties and call "finish-device" only after all properties are copied to the new nodes. At this point we particularly care about "reg" as this is the unit address which SLOF parses for us and sets the unit address in "finish-device"; we could skip other properties for later passes. Note this creates naked nodes with no methods normally added to the nodes as this bypasses normal discovery which SLOF performs at start. So if pass#1 does not find the node created in pass#0, this points to missing "decode-unit" at the new node parent (happens when adding bridge- under-bridge) and this prints a message and resets. While at this, fix few trailing spaces and comments. Signed-off-by: Alexey Kardashevskiy [groug: - use fdt-reg-unit to set the unit name - consolidate finish-device and unit name for nodes and subnodes with a new fdt-cas-finish-device word ] Signed-off-by: Greg Kurz --- board-qemu/slof/fdt.fs | 105 +++++++++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 46 deletions(-) diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs index e6a4fbe08950..8001382708da 100644 --- a/board-qemu/slof/fdt.fs +++ b/board-qemu/slof/fdt.fs @@ -112,7 +112,7 @@ fdt-check-header ; \ Lookup a string by index -: fdt-fetch-string ( index -- str-addr str-len ) +: fdt-fetch-string ( index -- str-addr str-len ) fdt-strings + dup from-cstring ; @@ -128,7 +128,7 @@ fdt-check-header ; \ Encode fdt property to OF property -: fdt-encode-prop ( addr len -- ) +: fdt-encode-prop ( addr len -- pa ps ) 2dup fdt-prop-is-string? IF 1- encode-string ELSE @@ -443,39 +443,17 @@ r> drop device-end ; -: fdt-create-cas-node ( name -- ) - 2dup - 2dup " memory@" find-substr 0 = IF - fdt-debug IF ." Creating memory@ " cr THEN - new-device - 2dup " @" find-substr nip device-name \ Parse the node name - 2dup - 2dup " @" find-substr rot over + 1 + -rot - 1 - \ Jump to addr afte "@" - parse-2int nip xlsplit set-unit \ Parse and set unit - finish-device - ELSE - 2dup " ibm,dynamic-reconfiguration-memory" find-substr 0 = IF - fdt-debug IF ." Creating ibm,dynamic-reconfiguration-memory " cr THEN - new-device - device-name - finish-device - ELSE - 2drop 2drop - false to fdt-cas-fix? - ." Node not supported " cr - EXIT - THEN - THEN - - find-node ?dup 0 <> IF set-node THEN -; - : str=phandle? ( s len -- true|false ) 2dup s" phandle" str= >r s" linux,phandle" str= r> or ; +: fdt-cas-finish-device ( -- ) + " reg" get-node get-package-property IF ELSE fdt-reg-unit THEN + get-node finish-device set-node +; + : (fdt-fix-cas-node) ( start -- end ) recursive fdt-next-tag dup OF_DT_BEGIN_NODE <> IF @@ -483,7 +461,7 @@ r> drop false to fdt-cas-fix? EXIT THEN drop - fdt-fetch-unit + fdt-fetch-unit ( a1 $name ) dup 0 = IF drop drop " /" THEN 40 left-parse-string 2swap ?dup 0 <> IF @@ -492,29 +470,52 @@ r> drop ELSE drop THEN - fdt-debug IF ." Setting node: " 2dup type cr THEN 2dup find-node ?dup 0 <> IF - set-node 2drop + set-node + fdt-debug IF ." Setting node: " 2dup type cr THEN + 2drop + \ newnode?=0: updating the existing node, i.e. pass1 adds only phandles + 0 ELSE + fdt-cas-pass 0 <> IF + \ We could not find the node added in the previous pass, + \ most likely because it is hotplug-under-hotplug case + \ (such as PCI brigde under bridge) when missing new node methods + \ such as "decode-unit" are critical. + \ Reboot when detect such case which is expected as it is a part of + \ ibm,client-architecture-support. + ." Cannot handle FDT update for the " 2dup type + ." node, rebooting" cr + reset-all + THEN fdt-debug IF ." Creating node: " 2dup type cr THEN - fdt-create-cas-node + new-device + 2dup " @" find-substr nip + device-name + \ newnode?=1: adding new node, i.e. pass1 adds all properties, + \ most importantly "reg". After reading properties, we call + \ "fdt-cas-finish-device" which sets the unit address from "reg". + 1 THEN - fdt-debug IF ." Current now: " pwd cr THEN + swap ( newnode? a1 ) + + fdt-debug IF ." Current now: " pwd get-node ." = " . cr THEN BEGIN fdt-next-tag dup OF_DT_END_NODE <> WHILE + ( newnode? a1 tag ) dup OF_DT_PROP = IF - drop dup ( drop tag, dup addr : a1 a1 ) - dup l@ dup rot 4 + ( fetch size, stack is : a1 s s a2) - dup l@ swap 4 + ( fetch nameid, stack is : a1 s s i a3 ) - rot ( we now have: a1 s i a3 s ) - fdt-encode-prop rot ( a1 s pa ps i) - fdt-fetch-string ( a1 s pa ps na ns ) + drop dup ( newnode? a1 a1 ) + dup l@ dup rot 4 + ( newnode? a1 s s a2) + dup l@ swap 4 + ( newnode? a1 s s i a3 ) + rot ( newnode? a1 s i a3 s ) + fdt-encode-prop rot ( newnode? a1 s pa ps i) + fdt-fetch-string ( newnode? a1 s pa ps na ns ) fdt-cas-pass CASE 0 OF - 2dup str=phandle? IF - fdt-debug IF 4dup ." Phandle: " type ." =" swap ." @" . ." " .d ." bytes" cr THEN + 2dup str=phandle? 7 pick or IF + fdt-debug IF 4dup ." Property: " type ." =" swap ." @" . ." " .d ." bytes" cr THEN property ELSE 4drop @@ -541,8 +542,14 @@ r> drop ENDCASE + 8 + 3 + fffffffc and - ELSE dup OF_DT_BEGIN_NODE = IF - drop ( drop tag ) + ELSE ( newnode? a1 tag ) + dup OF_DT_BEGIN_NODE = IF + 2 pick IF + rot drop 0 -rot + fdt-cas-finish-device + fdt-debug IF ." Finished node: " pwd get-node ." = " . cr THEN + THEN + drop ( a1 ) 4 - (fdt-fix-cas-node) get-parent set-node @@ -554,13 +561,19 @@ r> drop THEN THEN REPEAT - drop \ drop tag + ( newnode? a1 tag ) + drop + swap ( a1 newnode? ) + IF + fdt-cas-finish-device + fdt-debug IF ." Finished subnode: " pwd get-node ." = " . cr THEN + THEN ; : fdt-fix-cas-node ( start -- ) 0 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Add phandles 1 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Patch+add other properties - 2 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Delete phandles from pass 1 + 2 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Delete phandles from pass 0 drop ; From patchwork Wed Feb 5 18:21:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1233969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48CVK43Q5pz9sRs for ; Thu, 6 Feb 2020 05:22:16 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48CVK41xMWzDqLW for ; Thu, 6 Feb 2020 05:22:16 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=kaod.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=groug@kaod.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48CVJb6TmkzDqLW for ; Thu, 6 Feb 2020 05:21:51 +1100 (AEDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 015IIt9w109530 for ; Wed, 5 Feb 2020 13:21:49 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xyhpy31u3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 05 Feb 2020 13:21:49 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Feb 2020 18:21:47 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 5 Feb 2020 18:21:44 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 015ILhnX20447482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Feb 2020 18:21:43 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 906C811C058; Wed, 5 Feb 2020 18:21:43 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6826D11C050; Wed, 5 Feb 2020 18:21:43 +0000 (GMT) Received: from bahia.lan (unknown [9.145.71.236]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 5 Feb 2020 18:21:43 +0000 (GMT) From: Greg Kurz To: Alexey Kardashevskiy Date: Wed, 05 Feb 2020 19:21:42 +0100 In-Reply-To: <158092689078.2344237.6072760291677054493.stgit@bahia.lan> References: <158092689078.2344237.6072760291677054493.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20020518-0016-0000-0000-000002E3FF59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20020518-0017-0000-0000-00003346E15A Message-Id: <158092690266.2344237.14243967151310096030.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-05_05:2020-02-04, 2020-02-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 suspectscore=18 spamscore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1034 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002050140 Subject: [SLOF] [PATCH 2/3] fdt: Fix update of "interrupt-controller" node at CAS X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: slof@lists.ozlabs.org Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" Now that QEMU passes a full FDT at CAS without rebooting, a guest that has switched from XICS to XIVE ends up being presented an malformed "interrupt-controller" node in the DT: # dtc -I fs -O dts /proc/device-tree : Warning (unit_address_vs_reg): /interrupt-controller: node has a reg or ranges property, but no unit name ... interrupt-controller { ibm,xive-eq-sizes = <0x10>; device_type = "power-ivpe"; ibm,interrupt-server-ranges = <0x00 0x03>; compatible = "ibm,power-ivpe"; #interrupt-cells = <0x02>; reg = <0x60302 0x31b0000 0x00 0x10000 0x60302 0x31a0000 0x00 0x10000>; phandle = <0xe7448a8>; ibm,xive-lisn-ranges = <0x00 0x03>; interrupt-controller; }; The node should have its unit set to "60302031b0000" as reported by dtc. Also the node still has an "ibm,interrupt-server-ranges" property which only makes sense with XICS. This happens because we find an existing "interrupt-controller" node, which describes a XICS controller, and we _wrongly_ decide to copy all the properties from the new node into it. Delete the existing node instead so that we create a new node with the appropriate properties and unit name. Signed-off-by: Greg Kurz Reviewed-by: Alexey Kardashevskiy --- board-qemu/slof/fdt.fs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs index 8001382708da..66f8fe74d9dd 100644 --- a/board-qemu/slof/fdt.fs +++ b/board-qemu/slof/fdt.fs @@ -470,6 +470,20 @@ r> drop ELSE drop THEN + + fdt-cas-pass 0= IF + \ The guest might have asked to change the interrupt controller + \ type. It doesn't make sense to merge the new node and the + \ existing "interrupt-controller" node in this case. Delete the + \ latter. A brand new one will be created with the appropriate + \ properties and unit name. + 2dup " interrupt-controller" find-substr 0= IF + " interrupt-controller" find-node ?dup 0 <> IF + fdt-debug IF ." Deleting existing node: " dup .node cr THEN + delete-node + THEN + THEN + THEN 2dup find-node ?dup 0 <> IF set-node fdt-debug IF ." Setting node: " 2dup type cr THEN From patchwork Wed Feb 5 18:21:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1233970 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48CVKD4TrDz9sSb for ; Thu, 6 Feb 2020 05:22:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48CVKD1dzVzDqMT for ; Thu, 6 Feb 2020 05:22:24 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=kaod.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=groug@kaod.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48CVJj75M7zDqLg for ; Thu, 6 Feb 2020 05:21:57 +1100 (AEDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 015IFaUQ109331 for ; Wed, 5 Feb 2020 13:21:55 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xyhmdhst5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 05 Feb 2020 13:21:55 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Feb 2020 18:21:53 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 5 Feb 2020 18:21:50 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 015IKun831850770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Feb 2020 18:20:56 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8109EAE045; Wed, 5 Feb 2020 18:21:49 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59E54AE051; Wed, 5 Feb 2020 18:21:49 +0000 (GMT) Received: from bahia.lan (unknown [9.145.71.236]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 5 Feb 2020 18:21:49 +0000 (GMT) From: Greg Kurz To: Alexey Kardashevskiy Date: Wed, 05 Feb 2020 19:21:48 +0100 In-Reply-To: <158092689078.2344237.6072760291677054493.stgit@bahia.lan> References: <158092689078.2344237.6072760291677054493.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20020518-0028-0000-0000-000003D7B97C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20020518-0029-0000-0000-0000249C18FD Message-Id: <158092690859.2344237.16184914364427726409.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-05_05:2020-02-04, 2020-02-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 suspectscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002050140 Subject: [SLOF] [PATCH 3/3] fdt: Delete nodes of devices removed between boot and CAS X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: slof@lists.ozlabs.org Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" We recently fixed node creation at CAS in order to support early hotplug of devices between boot and CAS. Let's handle node removal now to support early hot *un*plug of devices. This is done in three phases: 1) all nodes from the boot time FDT are added a "slof,present-at-boot" property 2) during pass 0 of (fdt-fix-cas-node) all nodes from the CAS FDT are added a "slof,present-at-cas" property 3) loop on all nodes in the DT and delete the ones that only have the "slof,present-at-boot" property, and any alias they might have. In the same time, "slof,present-at-cas" properties are converted into "slof,present-at-boot" to allow further node removal in case of a subsequent device unplug and CAS sequence before quiesce (linux doesn't do that but it isn't explicitely forbidden by the spec). Signed-off-by: Greg Kurz --- board-qemu/slof/fdt.fs | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs index 66f8fe74d9dd..1125f6702435 100644 --- a/board-qemu/slof/fdt.fs +++ b/board-qemu/slof/fdt.fs @@ -198,6 +198,8 @@ fdt-check-header decode-int dup fdt-create-dec fdt-create-enc 2drop THEN + 0 0 s" slof,present-at-boot" property + finish-device ; @@ -514,6 +516,9 @@ r> drop swap ( newnode? a1 ) fdt-debug IF ." Current now: " pwd get-node ." = " . cr THEN + fdt-cas-pass 0= IF + 0 0 s" slof,present-at-cas" property + THEN BEGIN fdt-next-tag dup OF_DT_END_NODE <> WHILE @@ -584,8 +589,97 @@ r> drop THEN ; +: alias-dev-path ( xt -- dev-path len ) + link> execute decode-string 2swap 2drop +; + +: alias-name ( xt -- alias-name len ) + link> >name name>string +; + +: fdt-cas-alias-obsolete? ( node xt -- true|false ) + alias-dev-path rot node>path str= +; + +: (fdt-cas-delete-obsolete-aliases) ( node xt -- ) + dup IF + dup @ 2 pick swap ( node xt node next-xt ) + recurse ( node xt ) + 2dup fdt-cas-alias-obsolete? IF + dup alias-name ( node xt alias-name len ) + fdt-debug IF ." Deleting alias " 2dup type cr THEN + delete-property ( node xt ) + THEN + THEN + 2drop +; + +: fdt-cas-delete-obsolete-aliases ( node -- ) + s" /aliases" find-node dup IF + ( node aliases ) + get-node >r + dup set-node + + node>properties @ cell+ @ ( node xt ) + over swap ( node node xt ) + (fdt-cas-delete-obsolete-aliases) ( node ) + + r> set-node + THEN + drop +; + +: fdt-cas-node-obsolete? ( node -- true|false) + s" slof,present-at-cas" 2 pick get-package-property IF + s" slof,present-at-boot" 2 pick get-package-property IF + \ Node not coming from the QEMU + FALSE + ELSE + \ Device got removed since last boot or CAS + 2drop + TRUE + THEN + ELSE + 2drop ( node ) + + get-node >r + dup set-node + + \ Any device present in the CAS FDT is now considered as if it was + \ present at boot, ie. cold plugged. This allows a subsequent CAS + \ to remove the node from the DT if the device gets unplugged in + \ between). + s" slof,present-at-cas" delete-property + 0 0 s" slof,present-at-boot" property + + r> set-node + FALSE + THEN + nip +; + +: (fdt-cas-search-obsolete-nodes) ( start node -- ) + dup IF + dup child 2 pick swap recurse + dup peer 2 pick swap recurse ( start node ) + + fdt-debug IF dup ." Inspecting node: " dup .node ." = " . cr THEN + dup fdt-cas-node-obsolete? IF + fdt-debug IF ." Deleting node" cr THEN + dup fdt-cas-delete-obsolete-aliases + dup delete-node + THEN + THEN + 2drop +; + +: fdt-cas-delete-obsolete-nodes ( start -- ) + s" /" find-device get-node (fdt-cas-search-obsolete-nodes) +; + : fdt-fix-cas-node ( start -- ) 0 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Add phandles + dup fdt-cas-delete-obsolete-nodes \ Delete removed devices 1 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Patch+add other properties 2 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Delete phandles from pass 0 drop