ice: fix dpll data access on PF reset
Subsystems (2)
cover ice: fix dpll data access on PF reset
Do not allow to acquire data or alter configuration of dpll and pins if PF reset is in progress.
Arkadiusz Kubalewski (3):
ice: fix dpll and dpll_pin data access on PF reset
ice: fix dpll periodic work data updates on PF reset
ice: fix pin phase adjust updates on PF reset
drivers/net/ethernet/intel/ice/ice_dpll.c | 46 ++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)
base-commit: cef6969786db632a7948eed6a43ef9a71414ca5b
Signature · 1 line
2.38.1
PATCH 1/3 ice: fix dpll and dpll_pin data access on PF reset
Do not allow to acquire data or alter configuration of dpll and pins through firmware if PF reset is in progress, this would cause confusing netlink extack errors as the firmware cannot respond or process the request properly during the reset time.
Return (-EBUSY) and extack error for the user who tries access/modify the config of dpll/pin through firmware during the reset time.
The PF reset and kernel access to dpll data are both asynchronous. It is not possible to guard all the possible reset paths with any determinictic approach. I.e., it is possible that reset starts after reset check is performed (or if the reset would be checked after mutex is locked), but at the same time it is not possible to wait for dpll mutex unlock in the reset flow.
This is best effort solution to at least give a clue to the user what is happening in most of the cases, knowing that there are possible race conditions where the user could see a different error received from firmware due to reset unexpectedly starting.
Test by looping execution of below steps until netlink error appears:
- perform PF reset
$ echo 1 > /sys/class/net/<ice PF>/device/reset - i.e. try to alter/read dpll/pin config: $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \ --dump pin-get
--- drivers/net/ethernet/intel/ice/ice_dpll.c | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+)
drivers/net/ethernet/intel/ice/ice_dpll.c +38 -0
@@ -30,6 +30,26 @@ static const char * const pin_type_name[] = { [ICE_DPLL_PIN_TYPE_RCLK_INPUT] = "rclk-input", }; +/** +* ice_dpll_is_reset - check if reset is in progress +* @pf: private board structure +* @extack: error reporting +* +* If reset is in progress, fill extack with error. +* +* Return: +* * false - no reset in progress +* * true - reset in progress +*/ +static bool ice_dpll_is_reset (struct ice_pf *pf,struct netlink_ext_ack *extack) +{ +if (ice_is_reset_in_progress (pf->state)) { +NL_SET_ERR_MSG (extack,"pf reset in progress\n" ); +return true; + } +return false; +} +/** * ice_dpll_pin_freq_set - set pin's frequency * @pf: private board structure
@@ -109,6 +129,9 @@ ice_dpll_frequency_set(const struct dpll_pin *pin, void *pin_priv,struct ice_pf *pf = d->pf;int ret; +if (ice_dpll_is_reset (pf, extack)) +return -EBUSY ; +mutex_lock (&pf->dplls.lock); ret =ice_dpll_pin_freq_set (pf, p, pin_type, frequency, extack);mutex_unlock (&pf->dplls.lock);
@@ -584,6 +607,9 @@ ice_dpll_pin_state_set(const struct dpll_pin *pin, void *pin_priv,struct ice_pf *pf = d->pf;int ret; +if (ice_dpll_is_reset (pf, extack)) +return -EBUSY ; +mutex_lock (&pf->dplls.lock);if (enable) ret = ice_dpll_pin_enable(&pf->hw, p, d->dpll_idx, pin_type,
@@ -687,6 +713,9 @@ ice_dpll_pin_state_get(const struct dpll_pin *pin, void *pin_priv,struct ice_pf *pf = d->pf;int ret; +if (ice_dpll_is_reset (pf, extack)) +return -EBUSY ; +mutex_lock (&pf->dplls.lock); ret =ice_dpll_pin_state_update (pf, p, pin_type, extack);if (ret)
@@ -811,6 +840,9 @@ ice_dpll_input_prio_set(const struct dpll_pin *pin, void *pin_priv,struct ice_pf *pf = d->pf;int ret; +if (ice_dpll_is_reset (pf, extack)) +return -EBUSY ; +mutex_lock (&pf->dplls.lock); ret =ice_dpll_hw_input_prio_set (pf, d, p, prio, extack);mutex_unlock (&pf->dplls.lock);
@@ -1090,6 +1122,9 @@ ice_dpll_rclk_state_on_pin_set(const struct dpll_pin *pin, void *pin_priv,int ret = -EINVAL ;u32 hw_idx; +if (ice_dpll_is_reset (pf, extack)) +return -EBUSY ; +mutex_lock (&pf->dplls.lock); hw_idx = parent->idx - pf->dplls.base_rclk_idx;if (hw_idx >= pf->dplls.num_inputs)
@@ -1144,6 +1179,9 @@ ice_dpll_rclk_state_on_pin_get(const struct dpll_pin *pin, void *pin_priv,int ret = -EINVAL ;u32 hw_idx; +if (ice_dpll_is_reset (pf, extack)) +return -EBUSY ; +mutex_lock (&pf->dplls.lock); hw_idx = parent->idx - pf->dplls.base_rclk_idx;if (hw_idx >= pf->dplls.num_inputs)
Signature · 1 line
2.38.1
Tony Nguyen
maintainerRe: [Intel-wired-lan] [PATCH iwl-net 1/3] ice: fix dpll and dpll_pin data access on PF reset
On 2/7/2024 8:19 AM, Arkadiusz Kubalewski wrote:
...
drivers/net/ethernet/intel/ice/ice_dpll.c static const char * const pin_type_name[] = { · line 47
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dpll.c +4
-0+static bool ice_dpll_is_reset (struct ice_pf *pf,struct netlink_ext_ack *extack) +{ +if (ice_is_reset_in_progress (pf->state)) { +NL_SET_ERR_MSG (extack,"pf reset in progress\n" );
As pointed out by cocci:
drivers/net/ethernet/intel/ice/ice_dpll.c:47:25-49: WARNING avoid newline at end of message in NL_SET_ERR_MSG
Since this needs to be updated: s/pf/PF
drivers/net/ethernet/intel/ice/ice_dpll.c static const char * const pin_type_name[] = { · line 51
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dpll.c +4
-0+return true; + } +return false; +}
Thanks,
Tony
Re: [Intel-wired-lan] [PATCH iwl-net 1/3] ice: fix dpll and dpll_pin data access on PF reset
Quoted 17 lines
From: Nguyen, Anthony L <[email protected]>
Sent: Friday, February 9, 2024 7:52 PMOn 2/7/2024 8:19 AM, Arkadiusz Kubalewski wrote:
...
Quoted 1 line
+static bool ice_dpll_is_reset(struct
ice_pf*pf, structnetlink_ext_ack*extack)
drivers/net/ethernet/intel/ice/ice_dpll.c static const char * const pin_type_name[] = { · line 47
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c +3
-0+{ +if (ice_is_reset_in_progress (pf->state)) { +NL_SET_ERR_MSG (extack,"pf reset in progress\n" );As pointed out by cocci:
drivers/net/ethernet/intel/ice/ice_dpll.c:47:25-49: WARNING avoid newline at end of message inNL_SET_ERR_MSG
Quoted 2 lines
Since this needs to be updated: s/pf/PF
Sure, did in v2.
Thank you!
Arkadiusz
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_dpll.c static const char * const pin_type_name[] = { · line 51
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dpll.c +4
-0+return true; + } +return false; +}Thanks,
Tony
PATCH 2/3 ice: fix dpll periodic work data updates on PF reset
In reply to Arkadiusz KubalewskiDo not allow dpll periodic work function to acquire data from firmware if PF reset is in progress. Acquiring data will cause dmesg errors as the firmware cannot respond or process the request properly during the reset time.
Test by looping execution of below step until dmesg error appears:
- perform PF reset
$ echo 1 > /sys/class/net/<ice PF>/device/reset
--- drivers/net/ethernet/intel/ice/ice_dpll.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_dpll.c +4 -1
@@ -1364,8 +1364,10 @@ static void ice_dpll_periodic_work(struct kthread_work *work) struct ice_pf *pf = container_of(d, struct ice_pf, dplls);struct ice_dpll *de = &pf->dplls.eec;struct ice_dpll *dp = &pf->dplls.pps; -int ret; +int ret =0 ; +if (ice_is_reset_in_progress (pf->state)) + goto resched;mutex_lock (&pf->dplls.lock); ret =ice_dpll_update_state (pf, de, false);if (!ret)
@@ -1385,6 +1387,7 @@ static void ice_dpll_periodic_work(struct kthread_work *work)ice_dpll_notify_changes (de);ice_dpll_notify_changes (dp); +resched:/* Run twice a second or reschedule if update failed */ kthread_queue_delayed_work(d->kworker, &d->work, ret ? msecs_to_jiffies(10) :
Signature · 1 line
2.38.1
PATCH 3/3 ice: fix pin phase adjust updates on PF reset
In reply to Arkadiusz KubalewskiDo not allow to set phase adjust value for a pin if PF reset is in progress, this would cause confusing netlink extack errors as the firmware cannot process the request properly during the reset time.
Return (-EBUSY) and report extack error for the user who tries configure pin phase adjust during the reset time.
Test by looping execution of below steps until netlink error appears:
- perform PF reset
$ echo 1 > /sys/class/net/<ice PF>/device/reset
- change pin phase adjust value:
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \
--do pin-set --json '{"id":0, "phase-adjust":1000}'--- drivers/net/ethernet/intel/ice/ice_dpll.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ice/ice_dpll.c +3 -0
@@ -963,6 +963,9 @@ ice_dpll_pin_phase_adjust_set(const struct dpll_pin *pin, void *pin_priv,u8 flag, flags_en =0 ;int ret; +if (ice_dpll_is_reset (pf, extack)) +return -EBUSY ; +mutex_lock (&pf->dplls.lock);switch (type) {case ICE_DPLL_PIN_TYPE_INPUT :
Signature · 1 line
2.38.1
Re: [Intel-wired-lan] [PATCH iwl-net 3/3] ice: fix pin phase adjust updates on PF reset
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Arkadiusz Kubalewski
Sent: Wednesday, February 7, 2024 9:49 PM
To: [email protected]
Cc: Bagnucki, Igor <[email protected]>; Kubalewski, Arkadiusz <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net 3/3] ice: fix pin phase adjust updates on PF resetDo not allow to set phase adjust value for a pin if PF reset is in progress, this would cause confusing netlink extack errors as the firmware cannot process the request properly during the reset time.
Return (
-EBUSY) and report extack error for the user who tries configure pin phase adjust during the reset time.Test by looping execution of below steps until netlink error appears:
- perform PF reset$ echo 1 > /sys/class/net/<ice PF>/device/reset - change pin phase adjust value: $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \ --do pin-set --json '{"id":0, "phase-adjust":1000}'
Quoted 7 lines
Fixes 90e1c90750d7 ("ice: dpll: implement phase related callbacks")Reviewed-by Igor Bagnucki <[email protected]>Signed-off-by Arkadiusz Kubalewski <[email protected]>--- drivers/net/ethernet/intel/ice/ice_dpll.c | 3 +++ 1 file changed, 3 insertions(+)