mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krishna Kurapati PSSNV <quic_kriskura@quicinc.com>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	"Conor Dooley" <conor+dt@kernel.org>
Cc: <linux-usb@vger.kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	<linux-kernel@vger.kernel.org>,
	"Thinh Nguyen" <Thinh.Nguyen@synopsys.com>,
	Rob Herring <robh+dt@kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <quic_ppratap@quicinc.com>,
	<quic_jackp@quicinc.com>, <quic_wcheng@quicinc.com>,
	Andy Gross <agross@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Philipp Zabel <p.zabel@pengutronix.de>
Subject: Re: [RFC 2/8] usb: dwc3: core: Register vendor hooks for dwc3-qcom
Date: Sat, 4 Nov 2023 22:32:55 +0530	[thread overview]
Message-ID: <ea919050-22a8-4d28-ade2-fd16a99876cb@quicinc.com> (raw)
In-Reply-To: <cf553cd8-45f8-4a61-b016-69e7a80eee9f@linaro.org>




>>> Hi Bryan,
>>>
>>>> What happens to this code if you
>>>>
>>>> static int count;
>>>>
>>>> 1. sleep in dwc3_probe for 10 milliseconds
>>>> 2. return -EPROBE_DEFER
>>>> 3. if count++ < 5 goto 1
>>>>
>>>> i.e. if we simulate say waiting on a PHY driver to probe in 
>>>> dwc3_probe()
>>>>
>>> The vendor hooks are used in __dwc3_set_mode and role_switch_set 
>>> calls in core and drd files respectively. These are invoked only if 
>>> we are OTG capable. The drd_work is initialized in core_init_mode 
>>> which is called at the end of dwc3_probe. If dwc3_probe fails and 
>>> gets deferred before that, none of the vendor hooks will be fired and 
>>> dwc3_qcom_probe is also deferred.
>>>
>>> However I see that if core_init_mode fails (the cleanup is already 
>>> done in drd to prevent set_role from getting invoked already),  I 
>>> need to cleanup vendor hooks in error path of dwc3_probe().
>>>
>>>> and what happens if we introduce a 100 millsecond sleep into 
>>>> dwc3_qcom_probe() - and run a fake disconnect event from 
>>>> dwc3_qcom_probe_core() directly ?
>>>>
>>>> In other words if make it that dwc3_probe() completes and struct 
>>>> dwc3_glue_ops->notify_cable_disconnect() fires prior to 
>>>> dwc3_qcom_probe_core() completing ?
>>>>
>>>> i.e. I don't immediately see how you've solved the probe() 
>>>> completion race condition here.
>>>>
>>> Just wanted to understand the situation clearly. Is this the sequence 
>>> you are referring to ?
>>>
>>> 1. dwc3_probe is successful and role switch is registered properly.
>>> 2. added delay after dwc3_qcom_probe_core and before interconnect_init
>>> 3. Between this delay, we got a disconnect notificiation from glink
>>> 4. We are clearing the qscratch reg in case of device mode and 
>>> un-registering notifier in case of host mode.
>>>
>>> If so, firstly I don't see any issue if we process disconnect event 
>>> before qcom probe is complete. If we reached this stage, the 
>>> clocks/gdsc is definitely ON and register accesses are good to go.
>>>
>>> If we are in host mode at this point, we would just unregister to 
>>> usb-core notifier and mark last busy. If we are in device mode, we 
>>> would just clear the hs_phy_ctrl reg of qscratch. After the 100ms 
>>> delay you mentioned we would call dwc3_remove anyways and cleanup the 
>>> vendor hooks. But is the concern here that, what if we enter 
>>> runtime_suspend at this point ?
>>>
>>
>> Just to clarify one more thing. The probe completion requirement came 
>> in because, before the device tree was flattened, dwc3-qcom and core 
>> are two different platform devices. And if the dwc3 core device probe 
>> got deferred, dwc3-qcom probe still gets successfully completed. The 
>> glue would never know when to register vendor hook callbacks to 
>> dwc3-core as it would never know when the core probe was completed.
>>
>> That is the reason we wanted to find out accurate point where core 
>> probe is done to ensure we can properly register these callbacks.
> 
> Are you saying to you require/rely on both of these series being applied 
> first ?
> 
> [1]: 
> https://lore.kernel.org/all/af60c05b-4a0f-51b8-486a-1fc601602515@quicinc.com/
> [2]: 
> https://lore.kernel.org/all/20231016-dwc3-refactor-v1-0-ab4a84165470@quicinc.com/
> 
> Must be, nothing applies for me in this series.

The first one is not a patch. It is just a discussion thread I started 
to get community's opinion before on disconnect interrupt handling. The 
current series is based on top of [2] made by Bjorn (as you already 
found out) and as I mentioned in cover letter of my series.

Regards,
Krishna,

  reply	other threads:[~2023-11-04 17:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17 13:18 [RFC 0/8] Enable runtime suspend resume for QCOM devices Krishna Kurapati
2023-10-17 13:18 ` [RFC 1/8] dt-bindings: usb: qcom,dwc3: Add bindings to enable runtime Krishna Kurapati
2023-10-17 17:19   ` Krzysztof Kozlowski
2023-10-17 17:46     ` Krishna Kurapati PSSNV
2023-10-18  6:09       ` Krzysztof Kozlowski
2023-11-02 16:33   ` Caleb Connolly
2023-11-02 17:02     ` Krishna Kurapati PSSNV
2023-11-02 18:40       ` Caleb Connolly
2023-11-03  5:34         ` Krishna Kurapati PSSNV
2023-11-03 14:56           ` Caleb Connolly
2023-11-03 18:24             ` Krishna Kurapati PSSNV
2023-10-17 13:18 ` [RFC 2/8] usb: dwc3: core: Register vendor hooks for dwc3-qcom Krishna Kurapati
2023-11-03 15:14   ` Bryan O'Donoghue
2023-11-03 18:45     ` Krishna Kurapati PSSNV
2023-11-03 18:49       ` Krishna Kurapati PSSNV
2023-11-04 16:00         ` Bryan O'Donoghue
2023-11-04 17:02           ` Krishna Kurapati PSSNV [this message]
2023-11-07  8:33             ` Krishna Kurapati PSSNV
2023-11-07 10:41               ` Bryan O'Donoghue
2023-11-07 10:55                 ` Bryan O'Donoghue
2023-11-07 11:02                   ` Krishna Kurapati PSSNV
2023-10-17 13:18 ` [RFC 3/8] usb: dwc3: qcom: Enable autosuspend for host mode Krishna Kurapati
2023-10-17 13:18 ` [RFC 5/8] arm64: dts: qcom: Flatten sm8450 usb device node Krishna Kurapati
2023-10-17 13:18 ` [RFC 6/8] arm: dts: qcom: Add pmic glink support for sm8450-qrd Krishna Kurapati
2023-10-17 17:20   ` Krzysztof Kozlowski
2023-10-26 19:41   ` Konrad Dybcio
2023-10-27  3:30     ` Krishna Kurapati PSSNV
2023-10-17 13:18 ` [RFC 7/8] arm: dts: qcom: Enable runtime for SM8450 QRD Krishna Kurapati
2023-10-17 17:21   ` Krzysztof Kozlowski
2023-10-17 13:18 ` [RFC 8/8] usb: dwc3: core: Skip set_mode notification if cable is disconnected Krishna Kurapati

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=ea919050-22a8-4d28-ade2-fd16a99876cb@quicinc.com \
    --to=quic_kriskura@quicinc.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=bryan.odonoghue@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.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-usb@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=quic_jackp@quicinc.com \
    --cc=quic_ppratap@quicinc.com \
    --cc=quic_wcheng@quicinc.com \
    --cc=robh+dt@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®