Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2801625lqp; Mon, 25 Mar 2024 09:32:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgY58Y0xESGrPgYW8vwY9C6eIiV4vEvUivm3uJPBBQF3vIU+dCV+OmZH16IRuw1OuNTiCKjLL2AnH7mIvuRb/HVDHTNCvkB+4oDPUtEA== X-Google-Smtp-Source: AGHT+IGTf1afxlHQizhWIcI2OE+laRil26fzmp+fUh3ogQL4DsyPF2++/YPOW+KexdW+0nWQxIFM X-Received: by 2002:a05:6870:b14b:b0:22a:ba8:3ef2 with SMTP id a11-20020a056870b14b00b0022a0ba83ef2mr8153251oal.8.1711384378819; Mon, 25 Mar 2024 09:32:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711384378; cv=pass; d=google.com; s=arc-20160816; b=ado5NT63Zo5ZLYWiuoByK12b8fabi+NyWj06ySGuNR9fFDZmGoOo5FtiyOxnmAHUro jfVKmrNOggsxjtN6dHPioEQ1QzoofmoU/pEbXS8V3fF2Oq0Mq7k/emWKIHbpDqPEt+LK rERp5+9jiWcDlh9EFx3hzp/FhGzBT2Htq1Kb6SbgQA5QUSwAC6jFAj8ojcRGt6nDShQQ TW8B9ZA6pNi0UZE+c+tm8d+YMijmcwY6kR9gEa+lKELxVFuXiU1Xw5xfV6LNzrUaZqcr 87aM+ZQNB+Y9eZ4VclCpQ8NiYKTRIOGg7FmMhMGBJ7xjNo7DWq+mtnfvSbyoWRDYBxHS LvAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0j0+WJEClcsY1ZLRLTNOl6KxnRBJYlHp2TmN77gstlg=; fh=4NbdDCG5jJK4b9CvYk2BJKrmthNR82x/0DylsZ+cNoI=; b=wFGw8IhjcLc68G1CrklNqsD8lbp1kWpBveAHAnnIN4bQa914024f1K2Zz3TK44WnXR rQ7Nql/9RFkDNJ4Y1QEjKpSnTW9IZUOvWrb4hoDhT/eoGrKBIhkDtKTEz9eXDCwFzYEH zEjSIjc0qLNVul3Q++h9YYF/NIHa5QDYCIfUj8SewtfwuNdhV16a8oDTDYqTwPzUz1Jh K/YFucLzeq9pjkJ7J/NtimMXo0atE1tBnQctrj1F/tO1knA4SVMcCCiQu9iFcRzu7lDy wGzkQzb7DOvZ82B4dNNGOiYKDybj2rCgMhzmPxpDnwYV/lzCDekHS8Now1omeXkYxo5f Z4xA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X62YTIbH; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-117229-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117229-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q37-20020a635c25000000b005cda184c281si7446942pgb.199.2024.03.25.09.32.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 09:32:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117229-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X62YTIbH; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-117229-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117229-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AC8BB2892AC for ; Mon, 25 Mar 2024 16:21:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA1CE149E05; Mon, 25 Mar 2024 14:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="X62YTIbH" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 ECF681BC46 for ; Mon, 25 Mar 2024 14:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711376254; cv=none; b=Sdxpt/2si4fkZ2/CpKx0z/a/9+89V+u5CYCa6UnULy+1lpZrG/SeQq/dw62IGtc3Xkq60NubR+ZOpBqTrxXPOf3297nXZbglLARsp1jn33j6b2jHxqBfUXgIgaT9Ge+WeEUEdgCqMxVZLAvt9FZVJ7Cm92z8RlzUiU/OdMR8J4g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711376254; c=relaxed/simple; bh=AmZfqyfeQ8Y5M3qzBDAU3FZwTYWje8PwHZJoFRwwp+s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HlenZg9HLHdGsdm9ukZpL8EjgpLhF8ygIhP8dAWus4LHZjqFtHOTLNT4Luuo3wkobBi8okYc6+xLGHxs0S2dYj7tFKOqSg9zJhmNxwxUlJf/idPCuNObwofksKUjNnPJYONT/TcltgLQbwIKKUPjU6jnSG6f4CincxSS13Pt4Xw= 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=X62YTIbH; arc=none smtp.client-ip=209.85.210.171 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 Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e704078860so3014532b3a.0 for ; Mon, 25 Mar 2024 07:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711376251; x=1711981051; 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=0j0+WJEClcsY1ZLRLTNOl6KxnRBJYlHp2TmN77gstlg=; b=X62YTIbHKiAzOcSTne3x3j5N1YqE/6HsNRg8YWuBffDLP/gQ5LoJ/bvJrRI+kIOSq+ IU+eYKqafaRcZXStolpTt5X3+fzfi4DfSp1J6Rr+3hDKv3so7+r7XKLb4DWTYEzLxpIw VxTcyEtJrKtckMzJ24dkWTuEKiFBv3RX27B62igpzFQ810r/TS55b5gssUBKbgI1JlXa RfoarqF/4op/VhAE+CYgvOk9QxipajrP93jK3KHKn6urFEcvU9lXbygfrLeMpXWwGJu8 mPCeHCZ10YVCP/PC7MN1oAPMr9o4kmSPvNfhckvzOlCEP54et9RzXUlXsfk2dp04WyLH euNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711376251; x=1711981051; 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=0j0+WJEClcsY1ZLRLTNOl6KxnRBJYlHp2TmN77gstlg=; b=BWeq2GetMVdsYUoFIUEMJqPVC1TZqfnASAPnuPUuNprbhbphVQ08h9+VTPjUG54H/t rWP8CMProuolR6/hA+fZSv++RUnNTviMocoxU9dmqpzf5skr9LepSgPzD0W0Uki8iZHu 29DIPC3i4zu2a6KkXf+vlT4nXN7le9p1xMGZp7sscSerV/v+VDo0XUKxVotCpAQ3+EYl KBgBWY+EufdErgqlrUglsSNE7TvKO/BEjoTG8kZaE1unPyFpD0iMgqwNcu/wSMORkAW0 1FoUciYN76d2uQ0mZhdtLrh2aXjHaoT1P5GCPrvgRlzmDFqpWBu0iWkAxdZB8OKLuqr3 Yzpg== X-Forwarded-Encrypted: i=1; AJvYcCURVHu/mERwKCJ6E0hY0ByxBY33RzFjJGyU6OPV7DgdN3U/NThIRSZJeXWbSzrbqp9hwtPfq81pDaDPHSH/qxFGsqbIQrOlgHEwegRl X-Gm-Message-State: AOJu0YyIhEfn/3LO4nAnQqvZd2rfTBqrUrJ5Nfb6DKoAVfrz9JeVNeOL WVppGYNBkyw0SXIaFQUB4MFiRrszfsVRDZht/gnKpujbN+mRFjbR6j3V8cxaTA== X-Received: by 2002:a05:6a00:2345:b0:6e6:bb2b:882c with SMTP id j5-20020a056a00234500b006e6bb2b882cmr7821317pfj.13.1711376251041; Mon, 25 Mar 2024 07:17:31 -0700 (PDT) Received: from thinkpad ([117.207.29.15]) by smtp.gmail.com with ESMTPSA id x25-20020a056a00271900b006e24991dd5bsm4217943pfv.98.2024.03.25.07.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 07:17:30 -0700 (PDT) Date: Mon, 25 Mar 2024 19:47:06 +0530 From: Manivannan Sadhasivam To: Niklas Cassel Cc: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Marek Vasut , Yoshihiro Shimoda , Thierry Reding , Jonathan Hunter , Kishon Vijay Abraham I , Vidya Sagar , Vignesh Raghavendra , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Minghuan Lian , Mingkai Hu , Roy Zang , Kunihiko Hayashi , Masami Hiramatsu , Kishon Vijay Abraham I , Jesper Nilsson , Srikanth Thokala , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@axis.com Subject: Re: [PATCH v10 8/8] PCI: dwc: ep: Remove "core_init_notifier" flag Message-ID: <20240325141706.GD2938@thinkpad> References: <20240314-pci-dbi-rework-v10-0-14a45c5a938e@linaro.org> <20240314-pci-dbi-rework-v10-8-14a45c5a938e@linaro.org> 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: On Fri, Mar 22, 2024 at 12:53:50PM +0100, Niklas Cassel wrote: > On Thu, Mar 14, 2024 at 01:18:06PM +0530, Manivannan Sadhasivam wrote: > > "core_init_notifier" flag is set by the glue drivers requiring refclk from > > the host to complete the DWC core initialization. Also, those drivers will > > send a notification to the EPF drivers once the initialization is fully > > completed using the pci_epc_init_notify() API. Only then, the EPF drivers > > will start functioning. > > > > For the rest of the drivers generating refclk locally, EPF drivers will > > start functioning post binding with them. EPF drivers rely on the > > 'core_init_notifier' flag to differentiate between the drivers. > > Unfortunately, this creates two different flows for the EPF drivers. > > > > So to avoid that, let's get rid of the "core_init_notifier" flag and follow > > a single initialization flow for the EPF drivers. This is done by calling > > the dw_pcie_ep_init_notify() from all glue drivers after the completion of > > dw_pcie_ep_init_registers() API. This will allow all the glue drivers to > > send the notification to the EPF drivers once the initialization is fully > > completed. > > > > Only difference here is that, the drivers requiring refclk from host will > > send the notification once refclk is received, while others will send it > > during probe time itself. > > > > But this also requires the EPC core driver to deliver the notification > > after EPF driver bind. Because, the glue driver can send the notification > > before the EPF drivers bind() and in those cases the EPF drivers will miss > > the event. To accommodate this, EPC core is now caching the state of the > > EPC initialization in 'init_complete' flag and pci-ep-cfs driver sends the > > notification to EPF drivers based on that after each EPF driver bind. > > > > Signed-off-by: Manivannan Sadhasivam > > --- > > drivers/pci/controller/dwc/pci-dra7xx.c | 2 ++ > > drivers/pci/controller/dwc/pci-imx6.c | 2 ++ > > drivers/pci/controller/dwc/pci-keystone.c | 2 ++ > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 2 ++ > > drivers/pci/controller/dwc/pcie-artpec6.c | 2 ++ > > drivers/pci/controller/dwc/pcie-designware-plat.c | 2 ++ > > drivers/pci/controller/dwc/pcie-keembay.c | 2 ++ > > drivers/pci/controller/dwc/pcie-qcom-ep.c | 1 - > > drivers/pci/controller/dwc/pcie-rcar-gen4.c | 2 ++ > > drivers/pci/controller/dwc/pcie-tegra194.c | 1 - > > drivers/pci/controller/dwc/pcie-uniphier-ep.c | 2 ++ > > drivers/pci/endpoint/functions/pci-epf-test.c | 18 +++++------------- > > drivers/pci/endpoint/pci-ep-cfs.c | 9 +++++++++ > > drivers/pci/endpoint/pci-epc-core.c | 22 ++++++++++++++++++++++ > > include/linux/pci-epc.h | 7 ++++--- > > 15 files changed, 58 insertions(+), 18 deletions(-) > > FWIW: > Tested-by: Niklas Cassel > > > > However, when looking at this, I was surprised that you never call something > that will set: > init_complete = false; > from e.g. dw_pcie_ep_deinit() or dw_pcie_ep_cleanup(). > > I saw that you do seem to set > init_complete = false; > in your other follow up series that is based on this one. > > What will happen if you run with only this series merged (without your > follow up series), on a platform that used to have .core_init_notifier? > > If you do remove and recreate the symlink on a platform with external > refclk, since you never set init_complete to false, you could trigger > EPF core_init callback, e.g. pci_epf_test_core_init() to be called, > which will do DBI writes even when there is no refclk. > > E.g. (on a platform with external refclk): > 1) Create symlink to pci-epf-test in configfs. > 2) Start RC, your EPC driver will call ep_init_notifiy() when perst > deasserts. > 3) Run pci-epf-test. > 4) Remove the pci-epf-test symlink > 5) Shutdown RC > 6) Create symlink to pci-epf-test in configfs. > This will see that init_complete is true, and will do DBI writes > which will crash your system, since you don't have a refclk. > > Perhaps you should move the patch that calls a function that sets > init_complete = false; > to this series, so that this crash is not possible? > Good catch! But moving that patch to this series requires moving some other patches as well. So in the meantime, I'll set this flag to false in dw_pcie_ep_cleanup(). [...] > > diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c > > index 18c80002d3bd..fc0282b0d626 100644 > > --- a/drivers/pci/endpoint/functions/pci-epf-test.c > > +++ b/drivers/pci/endpoint/functions/pci-epf-test.c [...] > > - if (!core_init_notifier) { > > - ret = pci_epf_test_core_init(epf); > > - if (ret) > > - return ret; > > - } > > - > > While you did fix up all DWC based drivers, the non-DWC EPC drivers that > did not have epc_features->core_init_notifier before this patch: > > drivers/pci/controller/cadence/pcie-cadence-ep.c:#include > drivers/pci/controller/pcie-rcar-ep.c:#include > drivers/pci/controller/pcie-rockchip-ep.c:#include > > I don't think that they will work with pci-epf-test anymore, since AFAICT, > you did not add a call to: pci_epc_init_notify() or similar in these EPC drivers. > (Like this patch does to all the DWC-based drivers without a core_init_notifier.) > Doh, yeah I completely missed these. Thanks for pointing out. Will add the notify_init call in next version. - Mani -- மணிவண்ணன் சதாசிவம்