All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavan Holla <pholla@chromium.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
	 Pavan Holla <pholla@chromium.org>
Subject: [PATCH] usb: typec: ucsi: Wait 20ms before retrying reset
Date: Mon, 25 Mar 2024 21:19:43 +0000	[thread overview]
Message-ID: <20240325-ucsi-reset-delay-v1-1-d9e183e0f1e6@chromium.org> (raw)

The PPM might take time to process reset. Allow 20ms for the reset to
complete before issuing another reset.

Signed-off-by: Pavan Holla <pholla@chromium.org>
---
There is a 20ms delay for a reset retry to complete. However, the first
reset attempt is expected to complete immediately after an async write
of the reset command. This patch adds 20ms between the async write and
the CCI read that expects the reset to be complete. The additional delay
also allows the PPM to settle after the first reset, which seems to be
the intention behind the original 20ms delay ( kernel v4.14 has a comment
regarding the same )
---
 drivers/usb/typec/ucsi/ucsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index cf52cb34d285..6b642c4c58b7 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -1280,6 +1280,9 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
 			goto out;
 		}
 
+		/* Give the PPM time to reset and stabilize */
+		msleep(20);
+
 		ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
 		if (ret)
 			goto out;
@@ -1293,7 +1296,6 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
 				goto out;
 		}
 
-		msleep(20);
 	} while (!(cci & UCSI_CCI_RESET_COMPLETE));
 
 out:

---
base-commit: 4cece764965020c22cff7665b18a012006359095
change-id: 20240325-ucsi-reset-delay-bdf6712455fd

Best regards,
-- 
Pavan Holla <pholla@chromium.org>


             reply	other threads:[~2024-03-25 21:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 21:19 Pavan Holla [this message]
2024-03-26  8:29 ` [PATCH] usb: typec: ucsi: Wait 20ms before retrying reset Greg Kroah-Hartman
2024-03-26 23:34   ` Pavan Holla
2024-03-27 11:01     ` Heikki Krogerus
2024-03-27 23:12       ` Pavan Holla

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=20240325-ucsi-reset-delay-v1-1-d9e183e0f1e6@chromium.org \
    --to=pholla@chromium.org \
    --cc=abhishekpandit@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.