public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Dawid Niedzwiecki <dawidn@google.com>
Cc: Benson Leung <bleung@chromium.org>,
	chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
	chromeos-krk-upstreaming@google.com
Subject: Re: [PATCH 1/2] platform/chrome: cros_ec: jump to RW before probing
Date: Thu, 28 Nov 2024 04:29:32 +0000	[thread overview]
Message-ID: <Z0fxrDTuCIeCDTiV@google.com> (raw)
In-Reply-To: <20241125184446.1040187-1-dawidn@google.com>

On Mon, Nov 25, 2024 at 06:44:45PM +0000, Dawid Niedzwiecki wrote:
> To avoid such problems, send the RWSIG continue command first, which
> skips waiting for the jump to RW. Send the command more times, to make
> sure EC is ready in RW before the start of the actual probing process. If
> a EC device doesn't support the RWSIG, it will respond with invalid
> command error code and probing will continue as usual.

I'm wondering should it only send RWSIG_ACTION_CONTINUE if EC_CMD_GET_VERSION
shows the FW is still in RO.

Curious about: who (in which use case) is responsible for sending
RWSIG_ACTION_ABORT if it wants the EC stays in RO?

> diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
[...]
> @@ -204,6 +204,11 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
>  	mutex_init(&ec_dev->lock);
>  	lockdep_set_class(&ec_dev->lock, &ec_dev->lockdep_key);
>  
> +	/* Send RWSIG continue to jump to RW for devices using RWSIG. */
> +	err = cros_ec_rwsig_continue(ec_dev);
> +	if (err)
> +		dev_warn(dev, "Failed to continue RWSIG: %d\n", err);

Too verbose, use dev_info() instead.

> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
[...]
> +int cros_ec_rwsig_continue(struct cros_ec_device *ec_dev)
> +{
[...]
> +	for (int i = 0; i < RWSIG_CONTINUE_RETRIES; i++) {
> +		ret = cros_ec_send_command(ec_dev, msg);
> +
> +		if (ret < 0)
> +			error_count++;

Should it just return the error if the transmission fails?

> +		else if (msg->result == EC_RES_INVALID_COMMAND)
> +			/*
> +			 * If EC_RES_INVALID_COMMAND is retured, it means RWSIG
> +			 * is not supported or EC is already in RW, so there is
> +			 * nothing left to do.
> +			 */
> +			break;
> +		else if (msg->result != EC_RES_SUCCESS)
> +			/* Unexpected command error. */
> +			error_count++;

Same as `ret < 0`, should it just return if any unexpected errors?

> +		else
> +			/*
> +			 * The EC_CMD_RWSIG_ACTION succeed. Send the command
> +			 * more times, to make sure EC is in RW. A following
> +			 * command can timeout, because EC may need some time to
> +			 * initialize after jump to RW.
> +			 */
> +			error_count = 0;
> +
> +		if (error_count >= RWSIG_CONTINUE_MAX_ERRORS_IN_ROW)
> +			break;

It could return 0 if `error_count >= RWSIG_CONTINUE_MAX_ERRORS_IN_ROW`.

> +
> +		if (ret != -ETIMEDOUT)
> +			usleep_range(90000, 100000);
> +	}
> +
> +	kfree(msg);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL(cros_ec_rwsig_continue);

  parent reply	other threads:[~2024-11-28  4:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25 18:44 [PATCH 1/2] platform/chrome: cros_ec: jump to RW before probing Dawid Niedzwiecki
2024-11-25 18:44 ` [PATCH 2/2] platform/chrome: cros_ec_proto: remove unnecessary retries Dawid Niedzwiecki
2024-11-28  4:29 ` Tzung-Bi Shih [this message]
2024-12-02  9:16   ` [PATCH 1/2] platform/chrome: cros_ec: jump to RW before probing Dawid Niedźwiecki

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=Z0fxrDTuCIeCDTiV@google.com \
    --to=tzungbi@kernel.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=chromeos-krk-upstreaming@google.com \
    --cc=dawidn@google.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox