Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E54C4C4332F for ; Wed, 29 Dec 2021 11:12:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239870AbhL2LMu (ORCPT ); Wed, 29 Dec 2021 06:12:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239864AbhL2LMt (ORCPT ); Wed, 29 Dec 2021 06:12:49 -0500 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B661C06173E for ; Wed, 29 Dec 2021 03:12:49 -0800 (PST) Received: by mail-qv1-xf2e.google.com with SMTP id kk22so18943180qvb.0 for ; Wed, 29 Dec 2021 03:12:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=MK+wv3Q9ielT8iXy8qRJPd+VCDkiwmXUWkCOO3KJKF0=; b=trfeqc9D6qWnrrEa9clqEmsiT9mj3yY5MpLpvwvGKYl0byXxi5fjbNQf77oUFPD4nX 37oHLE4uVDzPkg+QYTQBKtFkGObyFfSxN2vhDK/tl8LgZ5Qo8uXj7OjFQ9WHk8trIvTz vAUZ/Qvb2Ri4cb43IzFnZr2oQHVDGZ66ElPJtAHF8kckpAgEn9lCYWAiym2Eff7Mx9ZT xH20GaE11w2JFvJcF6VK3SJYEUEctUrf/MnypX2S55Iyiy3pyjmJSdK+3odtC1zb0I0a njN9nj8cPcy6qdOUq/NSbL0GMTjkTTK0pATUfKCeDnTXI7FEmipw/08SRtgsWLts9VHn TWXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=MK+wv3Q9ielT8iXy8qRJPd+VCDkiwmXUWkCOO3KJKF0=; b=lFXnmgR/hw7q88hX4rafqmQGLhwSpo3MDGLuW7YGzrszTZZ4lGF+QYPGpIlkJvx4wg H01A1mrDz0hER4bKgUwf1v4mV7UOCcX32sG1+8xDGS7w316QrG3W/w+WxBrU7UqgWwsn JqR5CWmAXmR9T8MKa0O5+doZUGOV1ZN50FlakYgmJ70WSNiKh3/WFtHzHn8JWwmtzur7 UGDFulLR87W8jGqFUpuEDVjK4hsr2x2Lh7aXDCjJWRbXTWK1wQseKW2Xkzv1toCY8wBl xMSK165ZUPKUpOxCQb2n0iLOM7SdpWv598yjKDNGHH2ISg3nf8XeHTv3bnyPUqqhWUx5 9sNw== X-Gm-Message-State: AOAM532/KYUZcfzauNhSJwX4OVtNhulN14CVJfXQeaAsLdg+Fx0FW6sT 3pKFNPRbURBbNaXj4Dz3+a4jroFn9OLlbJBvGyEydw== X-Google-Smtp-Source: ABdhPJx/ycB9hnFgWIFMr485YIetQ5jMQIZjyS0fs06KaM88EI1mr4pBAJAI0mNqkQn08i9geel87TfDRgxCxnTz+sE= X-Received: by 2002:a05:6214:226e:: with SMTP id gs14mr23861400qvb.119.1640776368524; Wed, 29 Dec 2021 03:12:48 -0800 (PST) MIME-Version: 1.0 References: <1640189262-9699-1-git-send-email-quic_c_pmaliset@quicinc.com> In-Reply-To: From: Dmitry Baryshkov Date: Wed, 29 Dec 2021 14:12:37 +0300 Message-ID: Subject: Re: [PATCH v1] PCI: qcom: Add system PM support To: "Prasad Malisetty (Temp)" Cc: Prasad Malisetty , "agross@kernel.org" , "bjorn.andersson@linaro.org" , "lorenzo.pieralisi@arm.com" , "robh@kernel.org" , "kw@linux.com" , "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , quic_vbadigan , "Rama Krishna (QUIC)" , "manivannan.sadhasivam@linaro.org" , "swboyd@chromium.org" , quic_pmaliset , quic_skananth Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prasad, On Wed, 29 Dec 2021 at 13:59, Prasad Malisetty (Temp) wrote: > > Hi Dmitry, > > Thanks for the review and comments. > > Please find the response inline. Could you please use proper quoting nesting, it's hard to read if your answers are marked as level 2 quote (>>). > > Thanks > -Prasad > > -----Original Message----- > From: Dmitry Baryshkov > Sent: Thursday, December 23, 2021 8:44 PM > To: Prasad Malisetty > Cc: agross@kernel.org; bjorn.andersson@linaro.org; lorenzo.pieralisi@arm.= com; robh@kernel.org; kw@linux.com; bhelgaas@google.com; linux-pci@vger.ker= nel.org; linux-arm-msm@vger.kernel.org; linux-kernel@vger.kernel.org; quic_= vbadigan ; Rama Krishna (QUIC) ; manivannan.sadhasivam@linaro.org; swboyd@chromium.org; quic_pmali= set > Subject: Re: [PATCH v1] PCI: qcom: Add system PM support > > WARNING: This email originated from outside of Qualcomm. Please be wary o= f any links or attachments, and do not enable macros. > > On Wed, 22 Dec 2021 at 19:08, Prasad Malisetty wrote: > > > > From: Prasad Malisetty > > > > Add suspend_noirq and resume_noirq callbacks to handle System suspend > > and resume in dwc pcie controller driver. > > > > When system suspends, send PME turnoff message to enter link into L2 > > state. Along with powerdown the PHY, disable pipe clock, switch > > gcc_pcie_1_pipe_clk_src to XO if mux is supported and disable the pcie > > clocks, regulators. > > The GDSC stays on, if I'm not mistaken. Is this an expected behaviour for= the suspend procedure? > > >> No, GDSC will be disabled as part of system suspend. We are switching = gcc_pcie_1_clk_src to XO as GDSC should be enable in resume path. I think you should call the pm_runtime_suspend() kind of function to let the Linux core power down the GDSC power domains. > > Also as a side note, the qcom-pcie driver supports a variety of SoCs from= different generations. Which platforms were really tested? > Judging from your patch I suppose that you did not test this on any non-r= ecent platform. > > >> We have tested on SC7280 SoC which is recently added. Please take care and check that your code doesn't break previous generations. You are using structures specific to 2.7.0 from the generic code path. This is not legit. > > > When system resumes, PCIe link will be re-established and setup rc > > settings. > > > > Signed-off-by: Prasad Malisetty > > --- > > drivers/pci/controller/dwc/pcie-qcom.c | 103 > > +++++++++++++++++++++++++++++++++ > > 1 file changed, 103 insertions(+) > > > > diff --git a/drivers/pci/controller/dwc/pcie-qcom.c > > b/drivers/pci/controller/dwc/pcie-qcom.c > > index c19cd506..24dcf5a 100644 > > --- a/drivers/pci/controller/dwc/pcie-qcom.c > > +++ b/drivers/pci/controller/dwc/pcie-qcom.c > > @@ -73,6 +73,8 @@ > > > > #define PCIE20_PARF_Q2A_FLUSH 0x1AC > > > > +#define PCIE20_PARF_PM_STTS 0x24 > > + > > #define PCIE20_MISC_CONTROL_1_REG 0x8BC > > #define DBI_RO_WR_EN 1 > > > > @@ -1616,6 +1618,107 @@ static int qcom_pcie_probe(struct platform_devi= ce *pdev) > > return ret; > > } > > > > +static int qcom_pcie_send_pme_turnoff_msg(struct qcom_pcie *pcie) { > > + int ret =3D 0; > > + u32 val =3D 0, poll_val =3D 0; > > + uint64_t l23_rdy_poll_timeout =3D 100000; > > + struct dw_pcie *pci =3D pcie->pci; > > + struct device *dev =3D pci->dev; > > + > > + val =3D readl(pcie->elbi + PCIE20_ELBI_SYS_CTRL); > > + val |=3D BIT(4); > > + writel(val, pcie->elbi + PCIE20_ELBI_SYS_CTRL); > > + > > + ret =3D readl_poll_timeout((pcie->parf + PCIE20_PARF_PM_STTS), = poll_val, > > + (poll_val & BIT(5)), 10000, l23_rdy_poll_timeou= t); > > + if (!ret) > > + dev_dbg(dev, "PCIe: PM_Enter_L23 is received\n"); > > + else > > + dev_err(dev, "PM_Enter_L23 is NOT received.PARF_PM_STTS= 0x%x\n", > > + readl_relaxed(pcie->parf + > > + PCIE20_PARF_PM_STTS)); > > + > > + return ret; > > +} > > + > > +static void qcom_pcie_host_disable(struct qcom_pcie *pcie) { > > + struct qcom_pcie_resources_2_7_0 *res =3D &pcie->res.v2_7_0; > > + > > + /*Assert the reset of endpoint */ > > + qcom_ep_reset_assert(pcie); > > + > > + /* Put PHY into POWER DOWN state */ > > + phy_power_off(pcie->phy); > > + > > + writel(1, pcie->parf + PCIE20_PARF_PHY_CTRL); > > + > > + /* Disable pipe clock */ > > + pcie->ops->post_deinit(pcie); > > + > > + /* Change GCC_PCIE_1_PIPE_MUXR register to 0x2 for XO as parent= */ > > + if (pcie->pipe_clk_need_muxing) > > + clk_set_parent(res->pipe_clk_src, res->ref_clk_src); > > + > > + /* Disable PCIe clocks and regulators*/ > > + pcie->ops->deinit(pcie); > > +} > > + > > +static int __maybe_unused qcom_pcie_pm_suspend_noirq(struct device > > +*dev) { > > + int ret =3D 0; > > + struct qcom_pcie *pcie =3D dev_get_drvdata(dev); > > + struct dw_pcie *pci =3D pcie->pci; > > + > > + if (!dw_pcie_link_up(pci)) { > > + dev_err(dev, "Power has been turned off already\n"); > > + return ret; > > + } > > + > > + /* Send PME turnoff msg */ > > + ret =3D qcom_pcie_send_pme_turnoff_msg(pcie); > > + if (ret) > > + return ret; > > + > > + /* Power down the PHY, disable clock and regulators */ > > + qcom_pcie_host_disable(pcie); > > + > > + dev_info(dev, "PM: PCI is suspended\n"); > > + return ret; > > +} > > + > > +/* Resume the PCIe link */ > > +static int __maybe_unused qcom_pcie_pm_resume_noirq(struct device > > +*dev) { > > + int ret =3D 0; > > + struct qcom_pcie *pcie =3D dev_get_drvdata(dev); > > + struct dw_pcie *pci =3D pcie->pci; > > + struct pcie_port *pp =3D &pci->pp; > > + > > + dev_info(dev, "PM: Resuming\n"); > > + > > + /* Initialize PCIe host */ > > + ret =3D qcom_pcie_host_init(pp); > > + if (ret) > > + dev_err(dev, "cannot initialize host\n"); > > + > > + dw_pcie_iatu_detect(pci); > > + dw_pcie_setup_rc(pp); > > + > > + /* Start the PCIe link */ > > + qcom_pcie_start_link(pci); > > + > > + ret =3D dw_pcie_wait_for_link(pci); > > + if (ret) > > + dev_err(dev, "Link never came up, Resume failed\n"); > > + > > + return ret; > > +} > > + > > +static const struct dev_pm_ops qcom_pcie_pm_ops =3D { > > + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(qcom_pcie_pm_suspend_noirq, > > +qcom_pcie_pm_resume_noirq) }; > > + > > static const struct of_device_id qcom_pcie_match[] =3D { > > { .compatible =3D "qcom,pcie-apq8084", .data =3D &apq8084_cfg }= , > > { .compatible =3D "qcom,pcie-ipq8064", .data =3D &ipq8064_cfg }= , > > -- > > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a > > member of Code Aurora Forum, hosted by The Linux Foundation > > > > > -- > With best wishes > Dmitry --=20 With best wishes Dmitry