devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Bjorn Andersson <quic_bjorande@quicinc.com>
Cc: Vinod Koul <vkoul@kernel.org>,
	Kishon Vijay Abraham I <kishon@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/7] phy: qcom-qmp-combo: Introduce orientation variable
Date: Thu, 4 May 2023 17:41:33 +0200	[thread overview]
Message-ID: <ZFPSLTgOiPMgwHzP@hovoldconsulting.com> (raw)
In-Reply-To: <20230504151633.GH870858@hu-bjorande-lv.qualcomm.com>

On Thu, May 04, 2023 at 08:16:33AM -0700, Bjorn Andersson wrote:
> On Thu, May 04, 2023 at 03:44:53PM +0200, Johan Hovold wrote:
> > On Wed, May 03, 2023 at 08:29:07PM -0700, Bjorn Andersson wrote:
> > > On Tue, May 02, 2023 at 01:48:16PM +0200, Johan Hovold wrote:
> > > > On Mon, Apr 24, 2023 at 08:40:06PM -0700, Bjorn Andersson wrote:
> > 
> > > > >  static void qmp_v3_dp_aux_init(struct qmp_combo *qmp);
> > > > > @@ -1955,29 +1962,23 @@ static void qmp_v3_configure_dp_tx(struct qmp_combo *qmp)
> > > > >  static bool qmp_combo_configure_dp_mode(struct qmp_combo *qmp)
> > > > >  {
> > > > >  	u32 val;
> > > > > -	bool reverse = false;
> > > > > +	bool reverse = qmp->orientation == TYPEC_ORIENTATION_REVERSE;
> > 
> > > > It also looks like these callbacks end up being called without holding
> > > > the qmp->phy_mutex via phy->power_on(). Perhaps there is no risk for a
> > > > concurrent switch notification and dp phy power-on but it's not that
> > > > obvious.
> > 
> > > It seems we're arriving here from hpd_event_thread(), while
> > > phy_power_on() and phy_power_off() will be called in some other context.
> > > I've not been able to convince myself if DP driver ensures ordering, or
> > > if we have an existing race here...
> > 
> > > Unless you insist, I would prefer to follow up with an additional patch
> > > once we've landed this series. The fix will depend on the phy_mutex
> > > shuffling patch anyways...
> > 
> > Sure.
> > 
> > But perhaps you can just move the orientation == qmp->orientation check
> > under the mutex in qmp_combo_typec_switch_set() for now (in case I
> > forgot to point that out earlier).
> > 
> 
> qmp_combo_probe() and qmp_combo_typec_switch_set() are the only writers
> to qmp->orientation, so that check can't race with any updates and hence
> doesn't need to be protected.

Only if you happen to know that the callers of
qmp_combo_typec_switch_set() are serialised, right? That happens to be
the case for pmic_glink, but it may not be the case generally.
 
> Reading the code again, qmp_combo_configure_dp_mode() is invoked from
> phy_power_on(), not the hpd_event_thread(), as I claimed yesterday.

Yeah, but phy_power_on() is typically called from that thread. But
perhaps not only from there.

> But we shouldn't do qmp_combo_dp_power_on() in parallel with the
> reinitialization following a switch in orientation, qmp->orientation
> might change, but we definitely would have two contexts reconfiguring
> the hardware simultaneously - perhaps this was the cause for the 10%
> crashes I hit when trying to extend this to handle typec_mux as well...
> 
> I will grab the phy_mux in qmp_combo_configure_dp_mode() as well, thanks
> for "insisting" :)

:)

Johan

  reply	other threads:[~2023-05-04 15:41 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25  3:40 [PATCH 0/7] phy: qcom-qmp-combo: Support orientation switching Bjorn Andersson
2023-04-25  3:40 ` [PATCH 1/7] dt-bindings: phy: qcom,sc8280xp-qmp-usb43dp: Add ports and orientation-switch Bjorn Andersson
2023-04-25 18:58   ` Rob Herring
2023-04-26 10:21   ` Bryan O'Donoghue
2023-04-27 19:52     ` Bjorn Andersson
2023-05-03 20:37       ` Bryan O'Donoghue
2023-05-04 13:50       ` Neil Armstrong
2023-05-04 14:51         ` Bjorn Andersson
2023-04-25  3:40 ` [PATCH 2/7] phy: qcom-qmp-combo: Move phy_mutex out of com_init/exit Bjorn Andersson
2023-05-02 10:43   ` Johan Hovold
2023-04-25  3:40 ` [PATCH 3/7] phy: qcom-qmp-combo: Introduce orientation variable Bjorn Andersson
2023-04-27 13:13   ` Neil Armstrong
2023-05-02 11:48   ` Johan Hovold
2023-05-04  3:29     ` Bjorn Andersson
2023-05-04 13:44       ` Johan Hovold
2023-05-04 15:16         ` Bjorn Andersson
2023-05-04 15:41           ` Johan Hovold [this message]
2023-04-25  3:40 ` [PATCH 4/7] phy: qcom-qmp-combo: Introduce orientation switching Bjorn Andersson
2023-04-27 13:18   ` Neil Armstrong
2023-05-02 11:56   ` Johan Hovold
2023-04-25  3:40 ` [PATCH 5/7] phy: qcom-qmp-combo: Introduce drm_bridge Bjorn Andersson
2023-04-26 10:33   ` Bryan O'Donoghue
2023-04-27 13:11     ` Neil Armstrong
2023-04-27 18:00       ` Dmitry Baryshkov
2023-04-27 19:55     ` Bjorn Andersson
2023-04-28  6:55       ` Bryan O'Donoghue
2023-05-02 12:05   ` Johan Hovold
2023-05-04  3:13     ` Bjorn Andersson
2023-05-04  8:38       ` Johan Hovold
2023-05-04  8:55         ` Dmitry Baryshkov
2023-05-04 15:49         ` Bjorn Andersson
2023-04-25  3:40 ` [PATCH 6/7] arm64: dts: qcom: sc8280xp-crd: Add QMP to SuperSpeed graph Bjorn Andersson
2023-04-26 23:33   ` Konrad Dybcio
2023-04-27 13:27     ` Neil Armstrong
2023-05-02 11:03       ` Konrad Dybcio
2023-04-27 19:48     ` Bjorn Andersson
2023-05-02 12:22   ` Johan Hovold
2023-05-04  3:07     ` Bjorn Andersson
2023-04-25  3:40 ` [PATCH 7/7] arm64: dts: qcom: sc8280xp-x13s: " Bjorn Andersson
2023-04-25  4:58 ` [PATCH 0/7] phy: qcom-qmp-combo: Support orientation switching Steev Klimaszewski
2023-04-26 14:25 ` Abel Vesa
2023-05-02 12:26 ` Johan Hovold
2023-05-03  9:50 ` Neil Armstrong
2023-05-23  3:03 ` Bjorn Andersson

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=ZFPSLTgOiPMgwHzP@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=andersson@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kishon@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=quic_bjorande@quicinc.com \
    --cc=robh+dt@kernel.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;
as well as URLs for NNTP newsgroup(s).