From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F7EF197556 for ; Tue, 27 Aug 2024 08:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724748020; cv=none; b=TWANsxlj+U4uvSUIEqtVqX5/DwbT7n3SHW5vwjMPzmDFdVHfCRtiQi4oA74yOOcPCW8A2UciOK5mcdff1wIOT36v8dBxb8MMzLYV6AivfKd+rkvyreXsQbjb9eMI6w1T/LBKket3kxsBQX0+ZNnSJSJ98izk93bv87UOwXTaCLg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724748020; c=relaxed/simple; bh=9QN525WlZ9Yo78qHKye9xARuQKaUPonHRP2LxByxEI0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pL6WsJm7qxJ8PWlGhu3iEgEhUHpmcXRZRbWxK3xU0wRPHYdPXF28zGl86E67q4kdIMYVPmuNdhWuvh8g4Dl4buQyK+kWlKSfRU6zP/4hAUVqwBr3cLciw0vYytkuo2QmqGF13ltkL6DVpXR33AOPKsncegGy6Y6KFgcapBX022k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=k1M3jX64; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="k1M3jX64" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-71433cba1b7so3855344b3a.0 for ; Tue, 27 Aug 2024 01:40:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724748018; x=1725352818; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=W5DWQ30yzJUOL5OR+PUaG1BUHvOl8uCgiA5aV3iacTk=; b=k1M3jX64MIjnUEN7qmAYqW/1DnJyTYBYOVmqRAZ6JurokW2w0FetjuABcJAEdiXYBe 1hqQWUxqp0DTAmSQvZMOBJpzuhSjGpQN8wo8a3CyOE9p6isgrqnpfMYpXVwfkvJo2r04 Hyx9p6MnKwMfiq23y/Mg4P33LWDe4zzmUeQdfibmStwEKlIGrf4xd+KVItcGZoCjLb37 vUyM1dUZFpZJgu80Fi8gKEgsSub3nxAFXPutqDyxaeVE2uMGhQzvcbE2WFY1Qf17PqaJ 7HQoABLNxada2DR3pSvtVznde30I7Lvbpm7989jO5utH6Y1dC5dLrLeLlq8oYiAn+CtP SFrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724748018; x=1725352818; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W5DWQ30yzJUOL5OR+PUaG1BUHvOl8uCgiA5aV3iacTk=; b=CJZeER8/0iBCBIMVr40zm8EAYd5svbClNPmvuo1RRl2Hwt1c7KKAvXPTaTp2F6PTpB abt203OlwXfPJsqVaenKIcBIB1F3GBZ+nkucHktDMy0TvDZqCVyJDtEcZZBj4TMNjTxN b3jcfvdWMAZGlqq0zbOynv7GVcRtJcqdt+NNGYtHbINf7Xui1mtKIPI/hKxmhiPkTrb8 g3AKFW19ynOIXm4SDfa8hxjF0Mr5XXs+m4efhl1CzV9rSni1LeTCzD/u8CzqjVRPXNjC +8PTGybLiVcaT5RdE0KOGIsZbtULTEN8K5ONdy8Xcez94VJnvr/s9z7jrrhieAr15QIK EuIA== X-Forwarded-Encrypted: i=1; AJvYcCWGPq9Ix1GxD3J9wSzXU9divsCPYGGSZDCldy8LRXUs4XLXlV9fdr46T8fsY8Qw5+308Bu4DxVjJn678cE=@vger.kernel.org X-Gm-Message-State: AOJu0YwnI4ivg3ICIN51Rb9AkPfpsf/6tiM0Wyn5hNcPnbiNDc0GWnBU tD3oTA/uNpnVoW8F/x+FEU12tQJKfOfSwwtFBaaTQvvlR0U/5ANGoQVLm2wqXw== X-Google-Smtp-Source: AGHT+IG2iISKIuVAXaWnpPKXfM3PnhSGzIjpbXAu2gNEwo5d6yOloFEy2S4aiVBjPvBY9Z0qfA7pcw== X-Received: by 2002:a05:6a21:e591:b0:1be:c5ab:7388 with SMTP id adf61e73a8af0-1ccc08f1814mr2112530637.25.1724748018278; Tue, 27 Aug 2024 01:40:18 -0700 (PDT) Received: from thinkpad ([117.213.96.164]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203859f02e0sm78678985ad.250.2024.08.27.01.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 01:40:17 -0700 (PDT) Date: Tue, 27 Aug 2024 14:10:12 +0530 From: Manivannan Sadhasivam To: Bartosz Golaszewski , Rob Herring Cc: Bjorn Helgaas , Krishna chaitanya chundru , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH v3 1/2] PCI: don't rely on of_platform_depopulate() for reused OF-nodes Message-ID: <20240827084012.rjbfk4dhumunhaaa@thinkpad> References: <20240823093323.33450-1-brgl@bgdev.pl> <20240823093323.33450-2-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240823093323.33450-2-brgl@bgdev.pl> + Rob On Fri, Aug 23, 2024 at 11:33:22AM +0200, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > of_platform_depopulate() doesn't play nice with reused OF nodes - it > ignores the ones that are not marked explicitly as populated and it may > happen that the PCI device goes away before the platform device in which > case the PCI core clears the OF_POPULATED bit. We need to > unconditionally unregister the platform devices for child nodes when > stopping the PCI device. > It sounds like the fix is in of_platform_depopulate() itself and this patch works around the API issue in PCI driver. Rob, is that correct? - Mani > Fixes: 8fb18619d910 ("PCI/pwrctl: Create platform devices for child OF nodes of the port node") > Signed-off-by: Bartosz Golaszewski > --- > drivers/pci/remove.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c > index 910387e5bdbf..4770cb87e3f0 100644 > --- a/drivers/pci/remove.c > +++ b/drivers/pci/remove.c > @@ -1,7 +1,10 @@ > // SPDX-License-Identifier: GPL-2.0 > #include > #include > +#include > #include > +#include > + > #include "pci.h" > > static void pci_free_resources(struct pci_dev *dev) > @@ -14,12 +17,25 @@ static void pci_free_resources(struct pci_dev *dev) > } > } > > +static int pci_pwrctl_unregister(struct device *dev, void *data) > +{ > + struct device_node *pci_node = data, *plat_node = dev_of_node(dev); > + > + if (dev_is_platform(dev) && plat_node && plat_node == pci_node) { > + of_device_unregister(to_platform_device(dev)); > + of_node_clear_flag(plat_node, OF_POPULATED); > + } > + > + return 0; > +} > + > static void pci_stop_dev(struct pci_dev *dev) > { > pci_pme_active(dev, false); > > if (pci_dev_is_added(dev)) { > - of_platform_depopulate(&dev->dev); > + device_for_each_child(dev->dev.parent, dev_of_node(&dev->dev), > + pci_pwrctl_unregister); > device_release_driver(&dev->dev); > pci_proc_detach_device(dev); > pci_remove_sysfs_dev_files(dev); > -- > 2.43.0 > -- மணிவண்ணன் சதாசிவம்