Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp174436lqc; Thu, 29 Feb 2024 13:53:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUpNwZv07UtV3cxvGFMWLvBacZD7qXRR+WIR2lrdGICl00Dvixd8rluGw3BVHqGguHx2qblNZozgGRaJK+7qVJPf2av0zu94+wx1r83mw== X-Google-Smtp-Source: AGHT+IFcvJOWwAS3377LL4DPas496z+LW99o5bkjN/eMweEo29UYVsUpAuWtx/fbBu6aqNyHK/28 X-Received: by 2002:a05:6a20:e609:b0:1a1:2fde:3fb7 with SMTP id my9-20020a056a20e60900b001a12fde3fb7mr2353231pzb.43.1709243586061; Thu, 29 Feb 2024 13:53:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709243586; cv=pass; d=google.com; s=arc-20160816; b=NBvtfk4DQdi4Wy9eBUljO2sUYWsAG7WXfvuL+BJ2RqNXFKh/FSR4ZEvPSisrGz8mwa m1jtf2ozMOq9zx4Mvi2EHsQ49SXnafvXABU1cBa7h0YUMOTKDhEDB8N7F7hwstO6xOkV bCsG5MNCV0bg6xRJh6qhd6ETLcggNiHezDAFkMz+vWgZKULw17dmkSIwlelTfhQLO4h1 Sdz1daoa3tF8hORYe61pwXOfWziTooKAuqxY7giHpr/YaEUepnrYZgsbUWVVDpsEyDCF miOcC9cG8q9KTTsGJQenbtjYhSQbV2ulwsADF84AoaeeKnHd1xEpyg8pmYgBaVaXqUvw YuPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=bcxDBo3X6ADRmR5W/OgymaTAQ/nFMFQAEGMAozwd+U4=; fh=dzDHJUlDDP8olrk05geMnFtSRy7l6deqVbPsh0M3v+4=; b=fHEibm+NUzAisgbfJXHrplmiTpWeTyCw4vLPnhGVE3duDgnwinzLQsZEbkPrnKGzNU 39pDsTX6Jj3mI0lsMXkGO5VAP+4YACX1ZHau/siCxupFliWB+h2PcaWcfI1ZXIyThii/ kFG8V81uxRNI199v/ORmdhZT4ol9I1BnoaT4Hh4Qk5QehhXxDhtTJXeMK86xaVOHJ7Dk F1f015uKyBqpeE3LzyDK1y1DT/IJZxmeWx4GESXKqsLsNkimUahoopQ9GilifWSt+lr3 ueq2M4rXBM3Xn5RtOsGI6691MdJlLWU497fsBdGWc+p1sNLjaO42/CA442LOqUDAheYV AHOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n0Vzm2Za; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f3-20020a6547c3000000b005cfd3333850si2120367pgs.106.2024.02.29.13.53.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 13:53:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n0Vzm2Za; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E5489B2225E for ; Thu, 29 Feb 2024 21:51:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C90B86D51C; Thu, 29 Feb 2024 21:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n0Vzm2Za" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E20AC16FF45; Thu, 29 Feb 2024 21:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709243481; cv=none; b=LM10DkgLIrEzdE1z3oE1DQLmLBLAeJoJmlbWhmRXzt2zoNfr7t7DllYxmfvemJxduQaJwpf9ub6UrPa50WRLrTHjS7ndPT4oubJJervFq8qob/cLtSiPlsbcxuUB3qvbJJQanpFtUrbrrleljGScQJMfxOlTiZe93pjxSvrs1a8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709243481; c=relaxed/simple; bh=/JuCSNceDgZCs4G3fk9bR8SQ0x8xeT/iIC9so5k9Td0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=kW3KP1YcWbvSuhtFe1IEIIirYsb/b/2Vyzj1atsZ58GIjnJKtz60meWlhW32P/NhyuBf+W3XzoAAWTzwA1BvHZAbiuK3qBo3DCRQytJqKg0nZQn81EPCRBsBwHfKXa12eb8mlHuVRoTJaTWW+H3u0+hlIkoL9mkwRF3vE4C7a5g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n0Vzm2Za; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CF59C433F1; Thu, 29 Feb 2024 21:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709243480; bh=/JuCSNceDgZCs4G3fk9bR8SQ0x8xeT/iIC9so5k9Td0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=n0Vzm2ZayDGNrqnoFx14bdCqbyH4sYUechEdXzdXHrSOnQ0r2u8w6CSo4AR6kRUGf 6AsH1al4/Pgq/c2jOm5tWiJFwCMNMACCin4EjW4uUw2pwr7yWVA3ce2v4DLkyPbTUx vjfsxD8be6GJmtjwLs5xGqIAAkyquAkXr+QuRXh60w4oCEPzcrcwsSsB1WLQHeYLvU mARAwm2hIYC7aE5aaloJ1s2SodYjhfBJjxSF7MBL7lzq2+YA4c242X/kJUzQbOg55L KSv1AlvBkFTQ+ojTpg+qMH96xnUVhHqtc8E9GWS7lB88Jy8KC1W8lhcCNesC+c4YaY Fgdy9QGDAFxrQ== Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-513235b5975so1944127e87.2; Thu, 29 Feb 2024 13:51:20 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUcgKAI2BrGlBdUTcCHuQu4o+U4U6kZli5IbX2SxiToeG8EetgRk6q9j+EwfOP9SuSDccU9mcOgHaeXxMAvSagi4C/17KQETnrA31W7Z2pBciMc0YWzkfeHi8fT4vvlf3Uu7lLg/2V/Gg== X-Gm-Message-State: AOJu0Yxf6seRwdXO9evpchb0IXdqkbr8fGes5fzkhkMskoiM/0QLcOpv OnS4XsK63312f4ycczLc9xs2WGotS2Gp7A52PMf6ohoN65C/rV1RuzogwBppWP/SiWrNyPC44U6 t49s6o9MJBUYLf48VfMFiQhiNfA== X-Received: by 2002:a19:7516:0:b0:512:ec6e:9c67 with SMTP id y22-20020a197516000000b00512ec6e9c67mr2362718lfe.34.1709243418660; Thu, 29 Feb 2024 13:50:18 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240228062138.1275542-1-peng.fan@oss.nxp.com> In-Reply-To: From: Rob Herring Date: Thu, 29 Feb 2024 15:50:04 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] of: dynamic: notify before revert To: Peng Fan Cc: "Peng Fan (OSS)" , "saravanak@google.com" , "bhelgaas@google.com" , "pali@kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 29, 2024 at 2:01=E2=80=AFAM Peng Fan wrote: > > > Subject: Re: [PATCH] of: dynamic: notify before revert > > > > On Wed, Feb 28, 2024 at 12:13=E2=80=AFAM Peng Fan (OSS) > > wrote: > > > > > > From: Peng Fan > > > > > > When PCI node was created using an overlay and the overlay is > > > reverted/destroyed, the "linux,pci-domain" property no longer exists, > > > so of_get_pci_domain_nr will return failure. Then > > > of_pci_bus_release_domain_nr will actually use the dynamic IDA, even > > > if the IDA was allocated in static IDA. > > > > That usage is broken to begin with unless there is a guarantee that sta= tic and > > dynamic domain numbers don't overlap. For example, a dynamic number is > > assigned and then you load an overlay with the same number defined in i= t. > > I may not describe it clear, the code is here, because overlay property > removed, of_get_pci_domain_nr will return failure, so the code path > will goest into free a dynamic ida. But actually there is no such dynamic > ida, so dump. I understood the problem. Your usage of this is broken on applying your overlay. You just got lucky. > So the problem is overlay was removed, but the notify callback may > still use the property to do some work. > > static void of_pci_bus_release_domain_nr(struct pci_bus *bus, struct devi= ce *parent) > { > if (bus->domain_nr < 0) > return; > > /* Release domain from IDA where it was allocated. */ > if (of_get_pci_domain_nr(parent->of_node) =3D=3D bus->domain_nr) > ida_free(&pci_domain_nr_static_ida, bus->domain_nr); > else > ida_free(&pci_domain_nr_dynamic_ida, bus->domain_nr); > } > > > > > So move the notify before revert to fix the issue. > > > > You can't just change the timing. Something might require notify to be = after > > the revert. Again ^^^ > > > > > Fixes: c14f7ccc9f5d ("PCI: Assign PCI domain IDs by ida_alloc()") > > > > I don't see where the notifier is even used. > > The stack is as below: > > [ 595.150529] CPU: 1 PID: 582 Comm: jailhouse Tainted: G O = 6.5.0-rc4-next-20230804-05021-g3d4cc14b42ef-dirty #355 > [ 595.161998] Hardware name: NXP i.MX93 11X11 EVK board (DT) > [ 595.167475] Call trace: > [ 595.169908] dump_backtrace+0x94/0xec > [ 595.173573] show_stack+0x18/0x24 > [ 595.176884] dump_stack_lvl+0x48/0x60 > [ 595.180541] dump_stack+0x18/0x24 > [ 595.183843] pci_bus_release_domain_nr+0x34/0x84 > [ 595.188453] pci_remove_root_bus+0xa0/0xa4 > [ 595.192544] pci_host_common_remove+0x28/0x40 > [ 595.196895] platform_remove+0x54/0x6c > [ 595.200641] device_remove+0x4c/0x80 > [ 595.204209] device_release_driver_internal+0x1d4/0x230 > [ 595.209430] device_release_driver+0x18/0x24 > [ 595.213691] bus_remove_device+0xcc/0x10c > [ 595.217686] device_del+0x15c/0x41c > [ 595.221170] platform_device_del.part.0+0x1c/0x88 > [ 595.225861] platform_device_unregister+0x24/0x40 > [ 595.230557] of_platform_device_destroy+0xfc/0x10c > [ 595.235344] of_platform_notify+0x13c/0x178 > [ 595.239518] blocking_notifier_call_chain+0x6c/0xa0 > [ 595.244389] __of_changeset_entry_notify+0x148/0x16c > [ 595.249346] of_changeset_revert+0xa8/0xcc > [ 595.253437] jailhouse_pci_virtual_root_devices_remove+0x50/0x74 [jai= lhouse] $ git grep jailhouse_pci_virtual_root_devices_remove (END) Another out of tree overlay user. I have little interest in worrying about them. No one wants to step up and solve the problems with overlays, so I'm not going to worry about them either. Rob