Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp133688pxb; Fri, 16 Apr 2021 01:24:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3iWI7kcmYbZLJUFAGebBNb0boYmPJ8mwUiFx7PK9vDhfDSvWW92hMLLyeK7Cu4n6WkoTo X-Received: by 2002:a17:90b:4a04:: with SMTP id kk4mr8878250pjb.68.1618561459412; Fri, 16 Apr 2021 01:24:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618561459; cv=none; d=google.com; s=arc-20160816; b=Puy8Fd7W4UhXyw45eP/cz1fmrOQW9yDN80nCdy+I5D9IxZv/lc2nu+ttK9VwB/kAl0 /wwhlFO6MMqb8ZEdeF6suIkzXUqAxUjDg4UwhiV+6SPIVaYpBKT5aFZyrSFHUzJxUk1j B0tnBKVz+Pzos5O0GuCQJKxXD8vysokcNRS8vmngPW33fiio1rZw73Qvum+g+Uj7yQiW QqV5tEX0C3QbNXjD8CZXs/tnoDwJbmrQtx6p/Dzz7M1JSJxWRZ6oNqkGD9atUzXk1mTY Pl3/8KT7T/AvNOnjUGbYI6SEJK1A78Md/N8AxyFviZt1r3MLnWSviYBYMcWoPpB1wKSi RpOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=BzihCKLSn5zDahlSfxZpVN+H6HlVaY3GCUyxBAUfdLQ=; b=szf6rCnbd4R6ho50dRj27flY6ly8AbL5KgEe/LQ12DxhhzS/Bo8eB9hvVaMKYCMTgh 2TaTFP6iBhqtCb3GepIaP3HmtE0b4xHCuutOBB42Xs5Mb2x9MK/pmuuLwviWCujcxoMb 2M4Xt5w+6uirQ9cOm6MaXm6QGr/l7i2/UmWiwP1w94VykYbxhTzqzRDKXuIhGuz0UCKk 5cQdpSuN2N1nUODgsgEtEI4c5GQfsh/GPZ9IVUzAYy8vDlKI1/BpTrpgJ6CN2LyJ4aPM E9rKnD3RcCUW5WlluvuaHywTDRkE01IHPM2XX61p4P5p9j9qWa4iP/aX9ujI8rLWwx8f z9hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=YXGCN5pL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o2si5987556pfu.297.2021.04.16.01.24.04; Fri, 16 Apr 2021 01:24:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=YXGCN5pL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238823AbhDPHP3 (ORCPT + 99 others); Fri, 16 Apr 2021 03:15:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbhDPHP2 (ORCPT ); Fri, 16 Apr 2021 03:15:28 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3604C061574 for ; Fri, 16 Apr 2021 00:15:03 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id z22-20020a17090a0156b029014d4056663fso14126812pje.0 for ; Fri, 16 Apr 2021 00:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=BzihCKLSn5zDahlSfxZpVN+H6HlVaY3GCUyxBAUfdLQ=; b=YXGCN5pL3en+V1lnsbKkewxe6z62T9YCtJrt5Qgn59jA+RTQ7H/kg+KlNAoD2/aSeZ E9Flt7AmhulS59kAeBj7Rh/lNrPoV8fHug6KFClhT8g7WbGvhSAcrhJ1oNtCE/Z+0L1+ E0kBN5F6PriHe9zTWzS6ewqJA2NBOlokLxLhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=BzihCKLSn5zDahlSfxZpVN+H6HlVaY3GCUyxBAUfdLQ=; b=NMJjHPcoCZGXZ+FmQgW8yDJKqR5dncioZrbq2i4R62tQUa0PG5mxZZbiYGWCHM8fjn y+7r6K6wIxkfdj3HCSYZYi2qPWuYsOjn1Za400sZj5Xh/Zzbowip15iOo62iZs92Onrf Qr0ITjD+5HONvMmB2Meh7dv9dAicF6KtJabEnHMfCeGG3JjuThAkrAfbu+kWTfZ6MLqE KzR0hqPqdRz5xX1jkvK8Dr5/+8Qrq7y7oDUytgeF0OrmS79OqMs8EDJeT9R5U9tBDRN1 ffic2FEkItIqE6j6GFXWTPuQOW4qP2dtWq3mWv/WYEyDxTj1aB28256TFfl0R3g74fDC 17ow== X-Gm-Message-State: AOAM531xT7bByUuqI+LM3zekHCZ+hz0WZvnEXkKRKDvOTbLUvQysRfks TVPpfXjB9a989pwR6ZJUjfERDA== X-Received: by 2002:a17:90b:3b4e:: with SMTP id ot14mr7907331pjb.81.1618557303436; Fri, 16 Apr 2021 00:15:03 -0700 (PDT) Received: from localhost (2001-44b8-111e-5c00-09c3-a49e-2955-78c6.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:9c3:a49e:2955:78c6]) by smtp.gmail.com with ESMTPSA id e65sm4107570pfe.9.2021.04.16.00.15.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Apr 2021 00:15:03 -0700 (PDT) From: Daniel Axtens To: Tyrel Datwyler , mpe@ellerman.id.au Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Tyrel Datwyler Subject: Re: [PATCH] powerpc/pseries: extract host bridge from pci_bus prior to bus removal In-Reply-To: <20210211182435.47968-1-tyreld@linux.ibm.com> References: <20210211182435.47968-1-tyreld@linux.ibm.com> Date: Fri, 16 Apr 2021 17:15:00 +1000 Message-ID: <878s5ig0p7.fsf@linkitivity.dja.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tyrel, > The pci_bus->bridge reference may no longer be valid after > pci_bus_remove() resulting in passing a bad value to device_unregister() > for the associated bridge device. > > Store the host_bridge reference in a separate variable prior to > pci_bus_remove(). > The patch certainly seems to do what you say. I'm not really up on the innards of PCI, so I'm struggling to figure out by what code path pci_bus_remove() might invalidate pci_bus->bridge? A quick look at pci_remove_bus was not very illuminating but I didn't chase down every call it made. Kind regards, Daniel > Fixes: 7340056567e3 ("powerpc/pci: Reorder pci bus/bridge unregistration during PHB removal") > Signed-off-by: Tyrel Datwyler > --- > arch/powerpc/platforms/pseries/pci_dlpar.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c > index f9ae17e8a0f4..a8f9140a24fa 100644 > --- a/arch/powerpc/platforms/pseries/pci_dlpar.c > +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c > @@ -50,6 +50,7 @@ EXPORT_SYMBOL_GPL(init_phb_dynamic); > int remove_phb_dynamic(struct pci_controller *phb) > { > struct pci_bus *b = phb->bus; > + struct pci_host_bridge *host_bridge = to_pci_host_bridge(b->bridge); > struct resource *res; > int rc, i; > > @@ -76,7 +77,8 @@ int remove_phb_dynamic(struct pci_controller *phb) > /* Remove the PCI bus and unregister the bridge device from sysfs */ > phb->bus = NULL; > pci_remove_bus(b); > - device_unregister(b->bridge); > + host_bridge->bus = NULL; > + device_unregister(&host_bridge->dev); > > /* Now release the IO resource */ > if (res->flags & IORESOURCE_IO) > -- > 2.27.0