__dpll_pin_unregister() wiped the global sync-pair state on every
(dpll, ops, priv, cookie) tuple removed from a pin. When a pin is
registered multiple times and only one registration is being torn
down, this dropped sync-pair pairings still in use by the surviving
registrations.

Move dpll_pin_ref_sync_pair_del() inside the xa_empty(&pin->dpll_refs)
branch so it only runs when the last registration is gone, alongside
clearing the DPLL_REGISTERED mark.

Fixes: 58256a26bfb3 ("dpll: add reference sync get/set")
Signed-off-by: Grzegorz Nitka <[email protected]>
---
 drivers/dpll/dpll_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 58034be07080..ea45bb41376c 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -926,11 +926,12 @@ __dpll_pin_unregister(struct dpll_device *dpll, struct 
dpll_pin *pin,
                      const struct dpll_pin_ops *ops, void *priv, void *cookie)
 {
        ASSERT_DPLL_PIN_REGISTERED(pin);
-       dpll_pin_ref_sync_pair_del(pin->id);
        dpll_xa_ref_pin_del(&dpll->pin_refs, pin, ops, priv, cookie);
        dpll_xa_ref_dpll_del(&pin->dpll_refs, dpll, ops, priv, cookie);
-       if (xa_empty(&pin->dpll_refs))
+       if (xa_empty(&pin->dpll_refs)) {
+               dpll_pin_ref_sync_pair_del(pin->id);
                xa_clear_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED);
+       }
 }
 
 /**
-- 
2.39.3

Reply via email to