From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Sergey Temerkhanov <sergey.temerkhanov@intel.com>,
<intel-wired-lan@lists.osuosl.org>
Cc: <netdev@vger.kernel.org>
Subject: Re: [PATCH iwl-next v4 1/3] ice: Convert ctrl_pf pointer in struct ice_adapter to RCU
Date: Tue, 1 Sep 2026 14:43:36 +0200 [thread overview]
Message-ID: <db7fbcb4-743b-4ae6-9893-0e09caca15a9@intel.com> (raw)
In-Reply-To: <20260831161100.216773-2-sergey.temerkhanov@intel.com>
On 8/31/26 18:10, Sergey Temerkhanov wrote:
> Use RCU to ensure the consistent state of the control PF global
> pointer contained in struct ice_adapter. Enforce RCU usage on
> the callers.
>
> Fix a potential invalid pointer return due a TOCTOU issue
this is rather convincing/self explanatory
but the rule is "Fixes tags are for actual bug fixes, not theoretical
ones". (same comment for other patches).
Would be best if you could describe how to trigger the bug.
Or just drop the tag (since you target next- anyway).
>
> Fixes: e2193f9f9ec9 ("ice: enable timesync operation on 2xNAC E825 devices")
> Signed-off-by: Sergey Temerkhanov <sergey.temerkhanov@intel.com>
> Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
> Tested-by: Frederick Lawler <fred@cloudflare.com>
[...]
> --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> @@ -1,6 +1,7 @@
> // SPDX-License-Identifier: GPL-2.0
> /* Copyright (C) 2021, Intel Corporation. */
>
> +#include <linux/cleanup.h>
> #include <linux/delay.h>
> #include <linux/iopoll.h>
> #include "ice_common.h"
> @@ -335,6 +336,8 @@ void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd)
> struct ice_pf *pf = container_of(hw, struct ice_pf, hw);
> u32 cmd_val = ice_ptp_tmr_cmd_to_src_reg(hw, cmd);
>
> + guard(rcu)();
> +
> if (!ice_is_primary(hw))
> hw = ice_get_primary_hw(pf);
>
> @@ -353,6 +356,8 @@ static void ice_ptp_exec_tmr_cmd(struct ice_hw *hw)
> {
> struct ice_pf *pf = container_of(hw, struct ice_pf, hw);
>
> + guard(rcu)();
> +
> if (!ice_is_primary(hw))
> hw = ice_get_primary_hw(pf);
>
> @@ -2004,6 +2009,8 @@ static int ice_read_phy_and_phc_time_eth56g(struct ice_hw *hw, u8 port,
> zo = rd32(hw, GLTSYN_SHTIME_0(tmr_idx));
> lo = rd32(hw, GLTSYN_SHTIME_L(tmr_idx));
> } else {
> + guard(rcu)();
> +
> zo = rd32(ice_get_primary_hw(pf), GLTSYN_SHTIME_0(tmr_idx));
> lo = rd32(ice_get_primary_hw(pf), GLTSYN_SHTIME_L(tmr_idx));
> }
> @@ -2173,6 +2180,8 @@ int ice_start_phy_timer_eth56g(struct ice_hw *hw, u8 port)
> lo = rd32(hw, GLTSYN_INCVAL_L(tmr_idx));
> hi = rd32(hw, GLTSYN_INCVAL_H(tmr_idx));
> } else {
> + guard(rcu)();
> +
> lo = rd32(ice_get_primary_hw(pf), GLTSYN_INCVAL_L(tmr_idx));
> hi = rd32(ice_get_primary_hw(pf), GLTSYN_INCVAL_H(tmr_idx));
> }
guard() looks well suited for your use cases
> @@ -215,15 +221,18 @@ int ice_txclk_set_clk(struct ice_pf *pf, enum ice_e825c_ref_clk clk)
> void ice_txclk_update_and_notify(struct ice_pf *pf)
> {
> struct ice_ptp_port *ptp_port = &pf->ptp.port;
> - struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf);
> struct dpll_pin *old_pin = NULL;
> struct dpll_pin *new_pin = NULL;
> + struct ice_pf *ctrl_pf;
RCT rule counts whole line length, including assignement.
> struct ice_hw *hw = &pf->hw;
> enum ice_e825c_ref_clk clk;
> bool notify_dpll = false;
> int err;
> u8 phy;
>
> + guard(rwsem_read)(&pf->adapter->ctrl_pf_lock);
> + ctrl_pf = ice_get_ctrl_pf(pf);
> +
> phy = ptp_port->port_num / hw->ptp.ports_per_phy;
>
> /* Hold txclk_notify_rwsem for read across the entire critical
next prev parent reply other threads:[~2026-09-01 12:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 16:10 [PATCH iwl-next v4 0/3] Rework usage of the control PF pointer in struct ice_adapter Sergey Temerkhanov
2026-08-31 16:10 ` [PATCH iwl-next v4 1/3] ice: Convert ctrl_pf pointer in struct ice_adapter to RCU Sergey Temerkhanov
2026-09-01 12:43 ` Przemek Kitszel [this message]
2026-09-01 13:00 ` Temerkhanov, Sergey
2026-08-31 16:10 ` [PATCH iwl-next v4 2/3] ice: Zero out the PTP control PF pointer at ice_adapter cleanup Sergey Temerkhanov
2026-08-31 16:11 ` [PATCH iwl-next v4 3/3] ice: Cache struct ice_hw pointer for split register reads Sergey Temerkhanov
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=db7fbcb4-743b-4ae6-9893-0e09caca15a9@intel.com \
--to=przemyslaw.kitszel@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=netdev@vger.kernel.org \
--cc=sergey.temerkhanov@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