Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp667653pxb; Tue, 2 Feb 2021 14:58:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpVbgoXnWwofpkVnepREALlUSo+41wgIRdoJKamscgNe08mC9RpHry0RQ+XlGvh8CGDxz6 X-Received: by 2002:a17:906:c296:: with SMTP id r22mr288050ejz.158.1612306693352; Tue, 02 Feb 2021 14:58:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612306693; cv=none; d=google.com; s=arc-20160816; b=jUFjh5abtlx6QxCfmctQJbd+S4qXaZFdW7u2R2SSQ6Ov44eRnlxUpoLoa3T6DpURVT Nl53QEFZLQ1LUc8/ss4+RMSnpH/IUXvxJT3SNWWdK2OqVorILvjGEvFbQm3q8+VVJ63q nQ7kbX/CbGFIOBsTHqralZFkxX1WY9S89zyGaETHdH7F4+uZx8CSV6P9dyfpBB9PL+IG JuBB05yfVcsUZ+DRZS41PXX+qbN6bh8oowO/wD3TIIh6yytucmFG1UKAZa01Qw0E64tm A+whBrg3jLsqaK8wdfXytVfmJfreVen+Z5ate66pKrKixD8BReFCwzNmoP7Jii3Fwq5e 3zkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=fNaiUxfGZU0801X2bvX7kjP6nQhly13Sge0uoCH/7xc=; b=gxVv+LYjQjV9ZWKjh1W79xUrS0GtuhBgXnWUuwZDbnALdlbGeT31/ALgInbjwI5ggu hxFbnI8G0VsXb3MG5NNf7xn8XNF6KQ2n26hAviMOik26LBNqzfoZBln8NOrnvvPzYweo Mw/fGg5lsBQi+hiMxKQW2MswNKMOYUFrLkgv5bN1b8hKczD/jh3RtClFQZ1RS2nR5BOP CicYCaPt51JeO4b3sosQb3L7vkByoYPwON1pUR/hEsXrf9BfdH7UnvTgkzAg3kw31BpV 0RdavlJpNU9mbOXsrH+VTCIuwHX5ERl/NDZNc6rgANvDrASkUEBYuK29FZzYSKXE7Id0 ZeHw== ARC-Authentication-Results: i=1; mx.google.com; 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 g21si104277edb.12.2021.02.02.14.57.49; Tue, 02 Feb 2021 14:58:13 -0800 (PST) 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; 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 S236147AbhBBQPd (ORCPT + 99 others); Tue, 2 Feb 2021 11:15:33 -0500 Received: from mx.socionext.com ([202.248.49.38]:24641 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236073AbhBBQOA (ORCPT ); Tue, 2 Feb 2021 11:14:00 -0500 Received: from unknown (HELO iyokan2-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 03 Feb 2021 01:13:17 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by iyokan2-ex.css.socionext.com (Postfix) with ESMTP id A61A32059027; Wed, 3 Feb 2021 01:13:17 +0900 (JST) Received: from 172.31.9.53 (172.31.9.53) by m-FILTER with ESMTP; Wed, 3 Feb 2021 01:13:17 +0900 Received: from yuzu.css.socionext.com (yuzu [172.31.8.45]) by iyokan2.css.socionext.com (Postfix) with ESMTP id 00C77B1D40; Wed, 3 Feb 2021 01:13:17 +0900 (JST) Received: from [10.212.20.246] (unknown [10.212.20.246]) by yuzu.css.socionext.com (Postfix) with ESMTP id 511FE120148; Wed, 3 Feb 2021 01:13:16 +0900 (JST) Subject: Re: [PATCH v2 3/3] PCI: uniphier-ep: Add EPC restart management support To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Rob Herring , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Masami Hiramatsu , Jassi Brar References: <1611500977-24816-1-git-send-email-hayashi.kunihiko@socionext.com> <1611500977-24816-4-git-send-email-hayashi.kunihiko@socionext.com> From: Kunihiko Hayashi Message-ID: Date: Wed, 3 Feb 2021 01:13:15 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kishon, Thank you for your comment. On 2021/01/28 23:29, Kishon Vijay Abraham I wrote: > Hi Kunihiko, > > On 24/01/21 8:39 pm, Kunihiko Hayashi wrote: >> Set the polling function and call the init function to enable EPC restart >> management. The polling function detects that the bus-reset signal is a >> rising edge. >> >> Signed-off-by: Kunihiko Hayashi >> --- >> drivers/pci/controller/dwc/Kconfig | 1 + >> drivers/pci/controller/dwc/pcie-uniphier-ep.c | 44 ++++++++++++++++++++++++++- >> 2 files changed, 44 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig >> index 22c5529..90d400a 100644 >> --- a/drivers/pci/controller/dwc/Kconfig >> +++ b/drivers/pci/controller/dwc/Kconfig >> @@ -302,6 +302,7 @@ config PCIE_UNIPHIER_EP >> depends on OF && HAS_IOMEM >> depends on PCI_ENDPOINT >> select PCIE_DW_EP >> + select PCI_ENDPOINT_RESTART >> help >> Say Y here if you want PCIe endpoint controller support on >> UniPhier SoCs. This driver supports Pro5 SoC. >> diff --git a/drivers/pci/controller/dwc/pcie-uniphier-ep.c b/drivers/pci/controller/dwc/pcie-uniphier-ep.c >> index 69810c6..9d83850 100644 >> --- a/drivers/pci/controller/dwc/pcie-uniphier-ep.c >> +++ b/drivers/pci/controller/dwc/pcie-uniphier-ep.c >> @@ -26,6 +26,7 @@ >> #define PCL_RSTCTRL_PIPE3 BIT(0) >> >> #define PCL_RSTCTRL1 0x0020 >> +#define PCL_RSTCTRL_PERST_MON BIT(16) >> #define PCL_RSTCTRL_PERST BIT(0) >> >> #define PCL_RSTCTRL2 0x0024 >> @@ -60,6 +61,7 @@ struct uniphier_pcie_ep_priv { >> struct clk *clk, *clk_gio; >> struct reset_control *rst, *rst_gio; >> struct phy *phy; >> + bool bus_reset_status; >> const struct pci_epc_features *features; >> }; >> >> @@ -212,6 +214,41 @@ uniphier_pcie_get_features(struct dw_pcie_ep *ep) >> return priv->features; >> } >> >> +static bool uniphier_pcie_ep_poll_reset(void *data) >> +{ >> + struct uniphier_pcie_ep_priv *priv = data; >> + bool ret, status; >> + >> + if (!priv) >> + return false; >> + >> + status = !(readl(priv->base + PCL_RSTCTRL1) & PCL_RSTCTRL_PERST_MON); >> + >> + /* return true if the rising edge of bus reset is detected */ >> + ret = !!(status == false && priv->bus_reset_status == true); >> + priv->bus_reset_status = status; > > I'm still not convinced about having a separate library for restart > management but shouldn't we reset the function driver on falling edge? I understand your opnion well. There might not be enough way to give controller-specific features to handle "restart" as a common function. > After the rising edge the host expects the endpoint to be ready. I see. I didn't consider that restart was completed just after the rising edge. > Why not use the CORE_INIT (core_init_notifier) infrastructure? I don't follow the CORE_INIT yet, so I'll try to introduce it into the driver. However, our current controller doesn't have an interrupt that detects PERST like pcie-tegra194. I think the driver needs a thread for polling PERST like patch 2/3. Thank you, --- Best Regards Kunihiko Hayashi