Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Jan Sokolowski <jan.sokolowski@intel.com>,
	<intel-wired-lan@lists.osuosl.org>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v1 2/2] ice: add FW load wait
Date: Wed, 12 Jul 2023 00:18:40 +0200	[thread overview]
Message-ID: <55e0080d-4f37-4092-4987-a241cad3e2a4@intel.com> (raw)
In-Reply-To: <20230711122741.780900-2-jan.sokolowski@intel.com>

On 7/11/23 14:27, Jan Sokolowski wrote:
> As some cards load FW from external sources, we have to wait
> to be sure that FW is ready before setting link up.
> 
> Add check and wait for FW readyness

s/readyness/readiness/

> 
> Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com>
> ---
>   .../net/ethernet/intel/ice/ice_hw_autogen.h   |  2 +
>   drivers/net/ethernet/intel/ice/ice_main.c     | 41 +++++++++++++++++++
>   2 files changed, 43 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> index 20f40dfeb761..531cc2194741 100644
> --- a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> +++ b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> @@ -335,6 +335,8 @@
>   #define VP_MDET_TX_TCLAN_VALID_M		BIT(0)
>   #define VP_MDET_TX_TDPU(_VF)			(0x00040000 + ((_VF) * 4))
>   #define VP_MDET_TX_TDPU_VALID_M			BIT(0)
> +#define GL_MNG_FWSM				0x000B6134
> +#define GL_MNG_FWSM_FW_LOADING_M		BIT(30)
>   #define GLNVM_FLA				0x000B6108
>   #define GLNVM_FLA_LOCKED_M			BIT(6)
>   #define GLNVM_GENS				0x000B6100
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index e3245ee635b2..48991c6e94f5 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -4561,6 +4561,35 @@ static void ice_deinit_eth(struct ice_pf *pf)
>   	ice_decfg_netdev(vsi);
>   }
>   
> +/**
> + * ice_wait_for_fw - wait for full FW readiness
> + * @hw: pointer to the hardware structure
> + * @timeout: milliseconds that can elapse before timing out
> + */
> +static int ice_wait_for_fw(struct ice_hw *hw, u32 timeout)
> +{
> +	int fw_loading_register;

perhaps drop '_register' part of the name

> +	u32 elapsed = 0;
> +
> +	if (timeout == 0)
> +		return 0;
> +
> +	while (elapsed < timeout) {
> +		fw_loading_register = (rd32(hw, GL_MNG_FWSM) &
> +				       GL_MNG_FWSM_FW_LOADING_M);
> +
> +		/* firmware was not yet loaded, we have to wait more */
> +		if (fw_loading_register) {
> +			elapsed += 100;
> +			msleep(100);
> +			continue;
> +		}
> +		return 0;
> +	}
> +
> +	return -EIO;
> +}
> +
>   static int ice_init_dev(struct ice_pf *pf)
>   {
>   	struct device *dev = ice_pf_to_dev(pf);
> @@ -4573,6 +4602,18 @@ static int ice_init_dev(struct ice_pf *pf)
>   		return err;
>   	}
>   
> +	/* Some cards require longer initialization times
> +	 * due to necessity of loading FW from an external source.
> +	 * This can take even half a minute.
> +	 */
> +	if (ice_is_pf_c827(hw)) {
> +		err = ice_wait_for_fw(hw, 30000);
> +		if (err) {
> +			dev_err(dev, "ice_wait_for_fw timed out");
> +			return err;
> +		}
> +	}
> +
>   	ice_init_feature_support(pf);
>   
>   	ice_request_fw(pf);

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

  reply	other threads:[~2023-07-11 22:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 12:27 [Intel-wired-lan] [PATCH iwl-next v1 1/2] ice: Add get C827 PHY index function Jan Sokolowski
2023-07-11 12:27 ` [Intel-wired-lan] [PATCH iwl-next v1 2/2] ice: add FW load wait Jan Sokolowski
2023-07-11 22:18   ` Przemek Kitszel [this message]
2023-07-12 20:45   ` Tony Nguyen
2023-07-12 20:42 ` [Intel-wired-lan] [PATCH iwl-next v1 1/2] ice: Add get C827 PHY index function Tony Nguyen

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=55e0080d-4f37-4092-4987-a241cad3e2a4@intel.com \
    --to=przemyslaw.kitszel@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jan.sokolowski@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