Linux-USB Archive mirror
 help / color / mirror / Atom feed
From: Christian Ehrhardt <lk@c--e.de>
To: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
	neil.armstrong@linaro.org, quic_prashk@quicinc.com,
	dmitry.baryshkov@linaro.org, fabrice.gasnier@foss.st.com,
	saranya.gopal@intel.com, linux-usb@vger.kernel.org
Subject: Re: [RFC PATCH] usb: typec: ucsi: ack connector change after all tasks finish
Date: Thu, 25 Apr 2024 20:05:30 +0200	[thread overview]
Message-ID: <Ziqbata1wYNCadu+@cae.in-ulm.de> (raw)
In-Reply-To: <vvhn5le253djrcr6u2ksmphupgc4dot3x66hx53fpnhwbhqyma@hku4qvogc6at>

 
Hi Diogo,

On Wed, Apr 24, 2024 at 12:23:19PM +0100, Diogo Ivo wrote:
> Hi Christian, sorry for the late reply!
> 
> On Thu, Mar 28, 2024 at 11:40:09PM +0100, Christian Ehrhardt wrote:
> > 
> > On Thu, Mar 28, 2024 at 03:42:40PM +0000, Diogo Ivo wrote:
> > > On Wed, Mar 27, 2024 at 05:06:38PM +0100, Christian Ehrhardt wrote:
> > > > On Wed, Mar 27, 2024 at 12:39:04PM +0000, Diogo Ivo wrote:
> > > > > This fixes a problem with some LG Gram laptops where the PPM sometimes
> > > > > notifies the OPM with the Connector Change Indicator field set in the
> > > > > CCI after an ACK_CC_CI command is sent,causing the UCSI stack to check
> > > > > the connector status indefinitely since the EVENT_PENDING bit is already
> > > > > cleared. This causes an interrupt storm and an artificial high load on
> > > > > these platforms.
> > > > 
> > > > If the PPM does this for a connector change ACK_CC_CI command it is
> > > > IMHO violating the spec (unless there is a _new_ event).
> > > > When I saw this type of loops the connector change indicator was set
> > > > in response to an ACK_CC_CI command for a command (sent by a different
> > > > thread for a different connector) between clearing the EVENT_PENDING
> > > > bit and acquiring the PPM lock.
> > 
> > There are legitimate reaons why the connector change indicator
> > is set in response to a command:
> > - If the condition was reported previously it is sticky until
> >   cleared.
> > - Something else changed on the connector.
> > 
> > For a more complicated device that I have here, there are five
> > different connector change events after plugging it in.
> > 
> > I'd like to understand why you run into a loop here.
> > Printing the completed command (if any) and the CCI in
> > ucsi_acpi_notify() and the details of the connector status in
> > ucsi_handle_connector_change() could shed some light on this.
> 
> You are correct, my initial conclusions were not the cause of the issue.
> After digging a bit more with your ACK early patch set [1] applied the initial
> connector changes in CCI are meaningful:
> 
> /* Connect charge here */
> 
> [88248.531077] ucsi_acpi_notify: CCI: 20000002
> [88248.531084] scheduling connector change
> [88248.531094] COMMAND: 10012
> [88248.690705] ucsi_acpi_notify: CCI: 80000902
> [88248.705038] ucsi_acpi_notify: CCI: 80000902
> [88248.769716] MESSAGE_IN: 0 294024
> [88248.769721] COMMAND: 30004
> [88248.905117] ucsi_acpi_notify: CCI: 20000002
> [88248.905122] scheduling connector change
> [88248.905238] COMMAND: 10012
> [88248.921032] ucsi_acpi_notify: CCI: 20000002
> [88249.052045] ucsi_acpi_notify: CCI: 80000902
> [88249.094680] ucsi_acpi_notify: CCI: 80000902
> [88249.113033] MESSAGE_IN: 1 42851545402b0a44
> [88249.113036] COMMAND: 30004
> [88249.234930] ucsi_acpi_notify: CCI: 20000000
> 
> as the reply to GET_CONNECTOR_STATUS changes.
> 
> Turns out the problematic command seems to be the GET_PDOS for the
> source PDOs of the partner. After testing with multiple chargers and
> hubs we always have this pattern:
> 
> [88249.235144] COMMAND: 700810010
> [88249.431015] ucsi_acpi_notify: CCI: 80001000
> [88249.444510] ucsi_acpi_notify: CCI: 80001000
> [88249.474162] MESSAGE_IN: 641450004b12c 2d12c0801912c
> [88249.474164] COMMAND: 20004
> [88249.569839] ucsi_acpi_notify: CCI: 20000002
> [88249.569843] scheduling connector change
> [88249.569878] COMMAND: 604810010
> [88249.694744] ucsi_acpi_notify: CCI: 80000002
> [88249.756603] ucsi_acpi_notify: CCI: 80000002
> [88249.772341] MESSAGE_IN: 0 0
> [88249.772343] COMMAND: 20004
> [88249.796672] ucsi_acpi_notify: CCI: 80000002
> [88249.932743] ucsi_acpi_notify: CCI: 20000000
> 		...
> [88250.229964] COMMAND: 10012
> [88250.341815] ucsi_acpi_notify: CCI: 80000900
> [88250.385756] ucsi_acpi_notify: CCI: 80000900
> [88250.404292] MESSAGE_IN: 1 42851545402b0060
> 
> And the next time we check the partner source PDOS we get the same,
> 
> [88251.126928] COMMAND: 10012
> [88251.316607] ucsi_acpi_notify: CCI: 80000900
> [88251.330743] ucsi_acpi_notify: CCI: 80000900
> [88251.358123] MESSAGE_IN: 1 42851545402b0000
> [88251.358125] COMMAND: 20004
> [88251.474957] ucsi_acpi_notify: CCI: 20000000
> [88251.475109] COMMAND: 700810010
> [88251.636812] ucsi_acpi_notify: CCI: 80001000
> [88251.695686] ucsi_acpi_notify: CCI: 80001000
> [88251.709026] MESSAGE_IN: 641450004b12c 2d12c0801912c
> [88251.709028] COMMAND: 20004
> [88251.827071] ucsi_acpi_notify: CCI: 20000002
> [88251.827075] scheduling connector change
> [88251.827189] COMMAND: 604810010
> [88251.974138] ucsi_acpi_notify: CCI: 80000002
> [88252.034895] ucsi_acpi_notify: CCI: 80000002
> [88252.054572] ucsi_acpi_notify: CCI: 80000002
> [88252.067847] MESSAGE_IN: 0 0
> [88252.067849] COMMAND: 20004
> [88252.197648] ucsi_acpi_notify: CCI: 20000000
> 
> which then leads to the infinite loop. I have checked that we always get
> the same PDOs and nothing else is changing, leading me to believe that
> this change is not meaningful. The only thing that is changes are bits 5
> and 6 of the GET_CONNECTOR_STATUS reply that follows the GET_PDOS
> command.

If I understand your debug output correctly, each call to GET_PDOS
triggers a connector state change event. However, that event seems
to go away in CCI. In the connector status some changed bits remain.
These changed bits will cause us to re-read the PDOs resulting in
an infinite loop.

If this is about correct, I guess the simplest way to fix this would
be to enable the UCSI_NO_PARTNER_PDOS quirk for affected devices.


Best regards,
Christian

  reply	other threads:[~2024-04-25 18:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 12:39 [RFC PATCH] usb: typec: ucsi: ack connector change after all tasks finish Diogo Ivo
2024-03-27 13:06 ` Dmitry Baryshkov
2024-03-27 14:37   ` Diogo Ivo
2024-03-27 16:06 ` Christian Ehrhardt
2024-03-28 15:42   ` Diogo Ivo
2024-03-28 22:40     ` Christian Ehrhardt
2024-04-24 11:23       ` Diogo Ivo
2024-04-25 18:05         ` Christian Ehrhardt [this message]
2024-03-27 16:42 ` Christian Ehrhardt
2024-03-28 16:04   ` Diogo Ivo

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=Ziqbata1wYNCadu+@cae.in-ulm.de \
    --to=lk@c--e.de \
    --cc=diogo.ivo@tecnico.ulisboa.pt \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=fabrice.gasnier@foss.st.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=quic_prashk@quicinc.com \
    --cc=saranya.gopal@intel.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).