Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbdITRXJ (ORCPT ); Wed, 20 Sep 2017 13:23:09 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38076 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750825AbdITRXH (ORCPT ); Wed, 20 Sep 2017 13:23:07 -0400 Subject: Re: [mainline][DLPAR][Oops] OF: ERROR: Bad of_node_put() on /cpus To: Michael Ellerman , Rob Herring , abdul Cc: sachinp , Paul Mackerras , linuxppc-dev , linux-kernel References: <1505473476.9665.13.camel@abdul.in.ibm.com> <87bmm5lhuu.fsf@concordia.ellerman.id.au> From: Tyrel Datwyler Date: Wed, 20 Sep 2017 10:23:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <87bmm5lhuu.fsf@concordia.ellerman.id.au> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17092017-0024-0000-0000-00001738FC8B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007768; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000230; SDB=6.00919842; UDB=6.00462155; IPR=6.00700068; BA=6.00005599; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017223; XFM=3.00000015; UTC=2017-09-20 17:23:05 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092017-0025-0000-0000-00004CCC07A2 Message-Id: <3c15ac5c-c966-be45-1a6c-ba3fa1b9e439@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-20_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709200234 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1562 Lines: 54 On 09/20/2017 04:39 AM, Michael Ellerman wrote: > Rob Herring writes: > >> On Fri, Sep 15, 2017 at 6:04 AM, abdul wrote: >>> Hi, >>> >>> Mainline kernel panics during DLPAR CPU add/remove operation. >>> >>> Machine Type: Power8 PowerVM LPAR >>> kernel 4.13.0 >> >> Did 4.12 work or when was it last working? I'm not seeing anything >> recent in the DT code that looks suspicious. > > I'm pretty sure it's: > > int dlpar_attach_node(struct device_node *dn, struct device_node *parent) > { > int rc; > > dn->parent = parent; > > rc = of_attach_node(dn); > if (rc) { > printk(KERN_ERR "Failed to add device node %pOF\n", dn); > return rc; > } > > of_node_put(dn->parent); > HERE ^^^^^^^^^^ > > return 0; > } > > > Prior to 215ee763f8cb ("powerpc: pseries: remove dlpar_attach_node > dependency on full path"), we re-looked up the parent, and got another > reference on it. That meant the put before the return there was correct. > But now it's not because the caller has a reference to parent but it's > not ours to drop. > > Testing a fix, will report back. So, that patch slipped past me. Not only is the parent reference not ours to drop, but when I went and looked at dlpar_cpu_add() I also noticed that of_node_put() was done on the parent prior to the call to dlpar_attach_node(). With the addition of "parent" to the dlpar_attach_node() parameter list dlpar_cpu_add() needs to be fixed up to hold the "parent" reference until after dlpar_attach_node() returns. -Tyrel > > cheers >