From: Johan Hovold <johan@kernel.org>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: "Johan Hovold" <johan+linaro@kernel.org>,
"Andy Gross" <agross@kernel.org>,
"Bjorn Andersson" <bjorn.andersson@linaro.org>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Kishon Vijay Abraham I" <kishon@ti.com>,
"Vinod Koul" <vkoul@kernel.org>,
"Stephen Boyd" <swboyd@chromium.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Stanimir Varbanov" <svarbanov@mm-sol.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Prasad Malisetty" <quic_pmaliset@quicinc.com>,
linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-phy@lists.infradead.org
Subject: Re: [PATCH RFC 1/5] phy: qcom-qmp: add support for pipe clock muxing
Date: Fri, 22 Apr 2022 12:41:24 +0200 [thread overview]
Message-ID: <YmKGVP5T/ijPvV+g@hovoldconsulting.com> (raw)
In-Reply-To: <f4cfc1b3-2a85-f948-ff2c-27588cbe2210@linaro.org>
On Thu, Apr 21, 2022 at 02:36:05PM +0300, Dmitry Baryshkov wrote:
> On 21/04/2022 13:20, Johan Hovold wrote:
> > Some QMP PHYs need to remux to their pipe clock input to the pipe clock
> > output generated by the PHY before powering on the PHY and restore the
> > default source during power down.
> >
> > Add support for an optional pipe clock mux which will be reparented to
> > the generated pipe clock before powering on the PHY and restored to the
> > default reference source on power off.
> >
> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> > ---
> > +static int qcom_qmp_phy_pipe_clk_enable(struct qmp_phy *qphy)
> > +{
> > + struct qcom_qmp *qmp = qphy->qmp;
> > + int ret;
> > +
> > + ret = clk_set_parent(qphy->pipemux_clk, qmp->pipe_clksrc);
> > + if (ret)
> > + dev_err(qmp->dev, "failed to reparent pipe clock: %d\n", ret);
> > +
> > +
> > + ret = clk_prepare_enable(qphy->pipe_clk);
> > + if (ret) {
> > + dev_err(qmp->dev, "failed to enable pipe clock: %d\n", ret);
> > + goto err_restore_parent;
> > + }
>
> So, what you do here is you manually set the parent of
> GCC_PCIE_1_PIPE_CLK_SRC to PHY pipe clock right before enabling
> GCC_PCIE_1_PIPE_CLK and set it back to XO after disabling
> GCC_PCIE_1_PIPE_CLK.
>
> My proposal is doing exactly the same, but doing that automatically
> through the clock infrastructure. After removing pipe_clock handling
> from pcie driver itself, we can be sure that nobody is playing dirty
> tricks around the pipe_clock.
Yes, the end result is similar, but I believe handling it explicitly in
the driver is preferred for a number of reasons that I've already
mentioned. Not least because the mux needs to be updated when the PHY is
powered on, not when the GCC pipe clock is ungated.
In practise, powering on the PHY and ungating the clock happen to
coincide in time because only the PHY driver will use the GCC pipe
clock, but conceptually they are unrelated (and as the GDSC hang shows,
something in the system appears to be ungating the clock while the PHY
is powered off).
The QMP PHY driver implementation is much more straight forward and
easier to reason about than having the mux implementation spread out
over multiple clock drivers where it's not clear at all what is really
going on or why (and even debugfs will give you a false view of the
clock tree state).
> > +
> > + return 0;
> > +
> > +err_restore_parent:
> > + clk_set_parent(qphy->pipemux_clk, qphy->piperef_clk);
> > +
> > + return ret;
> > +}
> > +
> > +static void qcom_qmp_phy_pipe_clk_disable(struct qmp_phy *qphy)
> > +{
> > + struct qcom_qmp *qmp = qphy->qmp;
> > + int ret;
> > +
> > + clk_disable_unprepare(qphy->pipe_clk);
> > +
> > + ret = clk_set_parent(qphy->pipemux_clk, qphy->piperef_clk);
> > + if (ret)
> > + dev_err(qmp->dev, "failed to reparent pipe clock: %d\n", ret);
> > +}
> > +
Johan
next prev parent reply other threads:[~2022-04-22 10:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-21 10:20 [PATCH RFC 0/5] " Johan Hovold
2022-04-21 10:20 ` [PATCH RFC 1/5] " Johan Hovold
2022-04-21 11:08 ` Dmitry Baryshkov
2022-04-22 10:20 ` Johan Hovold
2022-04-22 10:35 ` Dmitry Baryshkov
2022-04-22 11:22 ` Johan Hovold
2022-04-28 16:15 ` Rob Herring
2022-04-21 11:36 ` Dmitry Baryshkov
2022-04-22 10:41 ` Johan Hovold [this message]
2022-04-28 13:11 ` Bjorn Andersson
2022-04-29 6:53 ` Johan Hovold
2022-04-21 10:20 ` [PATCH RFC 2/5] arm64: dts: qcom: sc7280: move pipe mux handling to phy Johan Hovold
2022-04-21 10:59 ` Dmitry Baryshkov
2022-04-22 10:07 ` Johan Hovold
2022-04-22 10:36 ` Dmitry Baryshkov
2022-04-21 10:20 ` [PATCH RFC 3/5] PCI: qcom: Remove unnecessary pipe_clk handling Johan Hovold
2022-04-21 10:20 ` [PATCH RFC 4/5] PCI: qcom: Drop pipe clock muxing Johan Hovold
2022-04-21 10:20 ` [PATCH RFC 5/5] PCI: qcom: Drop unused post-init callbacks Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YmKGVP5T/ijPvV+g@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=agross@kernel.org \
--cc=bhelgaas@google.com \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=johan+linaro@kernel.org \
--cc=kishon@ti.com \
--cc=krzk+dt@kernel.org \
--cc=kw@linux.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=quic_pmaliset@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=svarbanov@mm-sol.com \
--cc=swboyd@chromium.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®