Netdev List
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: Robert Malz <robert.malz@canonical.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	"Alexander Lobakin" <aleksander.lobakin@intel.com>,
	Jacob Keller <jacob.e.keller@intel.com>,
	Jesse Brandeburg <jbrandeb@kernel.org>
Cc: <intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH iwl] ice: acquire NVM lock around each flash read
Date: Tue, 14 Jul 2026 16:47:38 -0700	[thread overview]
Message-ID: <bc89cccb-3f22-42c9-9f96-382586d12fcf@intel.com> (raw)
In-Reply-To: <20260703103245.374800-1-robert.malz@canonical.com>



On 7/3/2026 3:32 AM, Robert Malz wrote:

...

> @@ -92,12 +98,28 @@ ice_read_flat_nvm(struct ice_hw *hw, u32 offset, u32 *length, u8 *data,
>   
>   		last_cmd = !(bytes_read + read_size < inlen);
>   
> +		status = ice_acquire_nvm(hw, ICE_RES_READ);
> +		if (status)
> +			break;
> +
>   		status = ice_aq_read_nvm(hw, ICE_AQC_NVM_START_POINT,
>   					 offset, read_size,
>   					 data + bytes_read, last_cmd,
>   					 read_shadow_ram, NULL);

Sashiko says:

If this chunk has last_cmd = false, doesn't releasing the NVM lock 
immediately
after ice_aq_read_nvm() allow other entities to acquire the lock and issue
their own NVM commands in the middle of our open read sequence?
Also, if ice_acquire_nvm() fails on the next loop iteration, the loop breaks
and we never send a command with last_cmd = true. Will this permanently leak
the sequence state in the firmware?

[TN] I'm seeing conflicting documentation on whether this bit matters 
for the read command. I'm working on getting clarification. If it does 
matter, we'll likely need to adjust this.

> -		if (status)
> +		if (status) {
> +			/* ice_release_nvm() issues an AQ command that would
> +			 * overwrite sq_last_status, which some callers
> +			 * inspect after a failed read. Preserve the read's
> +			 * AQ error across the release.
> +			 */
> +			aq_err = hw->adminq.sq_last_status;
> +
> +			ice_release_nvm(hw);
> +			hw->adminq.sq_last_status = aq_err;

Does restoring hw->adminq.sq_last_status here without holding the Admin 
Queue
lock risk overwriting the status of a concurrent AdminQ command?
If another thread acquires the lock and sends a command immediately after
ice_release_nvm(hw), this lockless write could corrupt its error status.

[TN] I don't believe the AQ lock will work as desired we can't guarantee 
that we will have the lock directly following the release in order to 
restore the AQ error. Similar to the NVM lock issue, I think this is a 
small window but wanted to bring this here in case others had 
thoughts/comments on this.

Thanks,
Tony

>   			break;
> +		}
> +
> +		ice_release_nvm(hw);
>   
>   		bytes_read += read_size;
>   		offset += read_size;



      parent reply	other threads:[~2026-07-14 23:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 10:32 [PATCH iwl] ice: acquire NVM lock around each flash read Robert Malz
2026-07-03 13:34 ` Przemek Kitszel
2026-07-06 20:56   ` Jacob Keller
2026-07-14 23:47 ` Tony Nguyen [this message]

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=bc89cccb-3f22-42c9-9f96-382586d12fcf@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jbrandeb@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=robert.malz@canonical.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