[PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock

Ivan Vecera posted 9 patches 1 week, 5 days ago
Documentation/driver-api/dpll.rst         |   48 +
drivers/dpll/.kunitconfig                 |    5 +
drivers/dpll/Kconfig                      |   13 +
drivers/dpll/Makefile                     |    1 +
drivers/dpll/dpll_core.c                  |  204 ++-
drivers/dpll/dpll_core.h                  |   34 +-
drivers/dpll/dpll_core_kunit.c            | 1580 +++++++++++++++++++++
drivers/dpll/dpll_netlink.c               |  117 +-
drivers/dpll/zl3073x/dpll.c               |    9 +-
drivers/net/ethernet/intel/ice/ice_dpll.c |   24 +-
drivers/net/ethernet/intel/ice/ice_dpll.h |    5 +
11 files changed, 1919 insertions(+), 121 deletions(-)
create mode 100644 drivers/dpll/.kunitconfig
create mode 100644 drivers/dpll/dpll_core_kunit.c
[PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Ivan Vecera 1 week, 5 days ago
dpll_lock protects topology and object lifetime, but it also serializes
all driver callbacks in the system, so one slow device stalls every other
DPLL device, whichever driver it belongs to. mlx5 callbacks issue firmware
commands with a 60 s default timeout, and zl3073x callbacks can wait
seconds on a driver lock held across ToD writes and phase steps.

Make dpll_lock an rwsem for topology and lifetime and add a mutex per
domain for callbacks. A domain is all objects created with one (module,
clock_id), in practice one chip or card, so channels of one chip stay
serialized as drivers expect, and they still block each other. Device
callbacks run under the domain of the device, pin callbacks under the
domain of the pin, whichever driver registered them. Only one domain lock
is ever held, so domains have no lock order. A lock per device would not
work, because pins are N:M with devices and callbacks notify sibling
channels.

The driver API does not change, but a callback can now notify only
objects of its own domain. Patch 1 changes the one in-tree callback that
does not follow this.

Registrations across domains exist in the tree only on E825, where ice
registers fwnode pins of an external DPLL with its TXC and TSPLL DPLLs.
These callbacks are no longer serialized with TXC and TSPLL, they rely on
pf->dplls.lock, and requests about these pins wait while the external
DPLL is busy. Intel folks, please check that this is fine.

Each complex of a dual complex E825 has its own DSN and so its own
domain, but both use the CGU of complex 0. The lock for the registers
they share is in a fix sent to net [1], which this series needs. Without
it a test lost updates of them.

Patch 4 is the only patch that lets callbacks run concurrently. Patch 5
adds KUnit tests. I also tested each commit with a mock driver and YNL in
QEMU, with lockdep and KASAN, and the tip with lockdep on two systems:

- A board with ZL30732A: every notification the driver sends from a
  callback, concurrent traffic with PTP, driver reload and rebind.
- GNR-D with dual complex E825 and zl3073x: callbacks of the pins shared
  by both drivers, TX clock switches, RCLK pins of both complexes, a port
  going down and up, and both drivers unloaded and loaded in either order
  under load.

mlx5 is build tested only.

On GNR-D, with ToD writes running on the zl3073x and requests waiting for
them, requests to an ice DPLL took 1448 ms in median and 3.9 s at most
before this series, 0.2 ms and 0.3 ms with it, the same as when idle.
Requests about the pins shared by both drivers still wait for the zl3073x.

Changes in v2:
- Dropped "ice: dpll: serialize changes of the SyncE CGU registers", sent
  to net with a fix of the SyncE divider [1]
- Addressed the Sashiko review, see the patches for details
- Added Reviewed-by tags from Petr

v1: https://lore.kernel.org/netdev/20261106121005.1327603-1-ivecera@redhat.com/

[1] https://lore.kernel.org/netdev/20261110094350.184185-1-ivecera@redhat.com/

Ivan Vecera (9):
  ice: dpll: notify TSPLL lock status from the periodic work only
  dpll: add domain object
  dpll: take domain locks around driver callbacks
  dpll: convert dpll_lock to rwsem
  dpll: add KUnit tests for core locking
  dpll: reject measured_freq_get for foreign and on-pin registrations
  dpll: zl3073x: update locking comments
  ice: dpll: update locking comments
  dpll: document locking rules

 Documentation/driver-api/dpll.rst         |   48 +
 drivers/dpll/.kunitconfig                 |    5 +
 drivers/dpll/Kconfig                      |   13 +
 drivers/dpll/Makefile                     |    1 +
 drivers/dpll/dpll_core.c                  |  204 ++-
 drivers/dpll/dpll_core.h                  |   34 +-
 drivers/dpll/dpll_core_kunit.c            | 1580 +++++++++++++++++++++
 drivers/dpll/dpll_netlink.c               |  117 +-
 drivers/dpll/zl3073x/dpll.c               |    9 +-
 drivers/net/ethernet/intel/ice/ice_dpll.c |   24 +-
 drivers/net/ethernet/intel/ice/ice_dpll.h |    5 +
 11 files changed, 1919 insertions(+), 121 deletions(-)
 create mode 100644 drivers/dpll/.kunitconfig
 create mode 100644 drivers/dpll/dpll_core_kunit.c


base-commit: 368fbf5d82da9ebce309449c74fc0b128f7d0219
-- 
2.56.0
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Jakub Kicinski 1 week ago
On Wed, 11 Nov 2026 17:40:11 +0100 Ivan Vecera wrote:
> dpll_lock protects topology and object lifetime, but it also serializes
> all driver callbacks in the system, so one slow device stalls every other
> DPLL device, whichever driver it belongs to. mlx5 callbacks issue firmware
> commands with a 60 s default timeout, and zl3073x callbacks can wait
> seconds on a driver lock held across ToD writes and phase steps.

Can you provide some real life data of how much this actually helps?
Real device topology + scenario you hit?

For the cross-domain pins - shouldn't we stretch the domain to cover
all interconnected objects on the system instead of hoping people get
lock ordering right? You documented some rules in the doc, admittedly,
but not sure how enforceable and practical they are.
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Ivan Vecera 5 days, 13 hours ago
On 11/17/26 03:16, Jakub Kicinski wrote:
> On Wed, 11 Nov 2026 17:40:11 +0100 Ivan Vecera wrote:
>> dpll_lock protects topology and object lifetime, but it also serializes
>> all driver callbacks in the system, so one slow device stalls every other
>> DPLL device, whichever driver it belongs to. mlx5 callbacks issue firmware
>> commands with a 60 s default timeout, and zl3073x callbacks can wait
>> seconds on a driver lock held across ToD writes and phase steps.
> 
> Can you provide some real life data of how much this actually helps?
> Real device topology + scenario you hit?

The system is GNR-D with a dual complex E825 and a ZL30732 on the
board. The zl3073x has its own PHC, takes the recovered clocks of the
E825 ports and feeds the TX and time reference clocks of the E825. Each
ice PF connects to the zl3073x like this:

   +------------------------- zl3073x --------------------------+
   |   EEC DPLL, PPS DPLL                                       |
   |                                                            |
   |   input pin                       output pin               |
   |   (recovered clock of E825)       156M25_NAC0_CLKREF_SYNC  |
   +-------^---------------------------------|------------------+
           | parent pin                      | registered with
           | dpll_pin_on_pin_register()      | dpll_pin_register()
   +-------|---------------------------------v------------------+
   |   RCLK pin                         TXC DPLL                |
   +------------------------- ice PF ---------------------------+

The PF owning the source timer also registers the zl3073x output pin
156M25_NAC0_TIMEREF_SYNC with its TSPLL DPLL.

A step of the zl3073x PHC, which ptp4l and ts2phc do at start and after
a large offset, waits for the next 1 PPS edge, up to 1 s, with the
channel lock held. A phase step can hold it for up to 3 s while it
waits for the previous one. A dpll callback of that channel waits for
the lock under dpll_lock, and every other DPLL request and notification
in the system waits behind it. With ToD writes running, requests to an
ice DPLL took 1448 ms in median and 3.9 s at most. With the series they
took 0.2 ms and 0.3 ms, the same as idle.

The bigger reason are zl3073x callbacks we are working on, which have
to wait for the hardware themselves:

- a device reset with resync waits for the fast lock, up to 1 s with a
   1 PPS input
- a glitchless stop or start of an output completes on an output edge,
   so it takes up to one period, 1 s for a 1 PPS output

Holding the global dpll_lock for that long would stall every DPLL
device in the system. For the output state we tried an asynchronous
implementation, but then the callback returns success before it knows
the result. A failure can only be reported by a later notification, and
the next request gets -EBUSY until the change completes. With a lock
per chip the callback can simply wait, and one chip cannot do these
operations in parallel anyway.

> For the cross-domain pins - shouldn't we stretch the domain to cover
> all interconnected objects on the system instead of hoping people get
> lock ordering right? You documented some rules in the doc, admittedly,
> but not sure how enforceable and practical they are.

Stretching the domains would not improve anything here. The only
in-tree registrations across domains are the ones in the diagram above,
and every PF connects to the zl3073x, so the zl3073x and all ice PFs
would end up in one domain. The system above would then stall the same
way as with the global lock.

There is no lock ordering to get right. Only one domain lock is ever
held and all of them share one lockdep class, so any nesting is
reported. __dpll_{device,pin}_change_ntf() assert the domain lock of
the object, so a callback notifying an object of another domain is
reported as well. The rule that a callback must not call functions
taking dpll_lock holds on main already. What lockdep cannot check is
that a driver registering a pin of another driver protects the state
these callbacks share with its own ones. ice is the only such driver
and uses pf->dplls.lock for it.

Thanks,
Ivan
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Jakub Kicinski 5 days, 2 hours ago
On Wed, 18 Nov 2026 16:29:23 +0100 Ivan Vecera wrote:
> A step of the zl3073x PHC, which ptp4l and ts2phc do at start and after
> a large offset, waits for the next 1 PPS edge, up to 1 s, with the
> channel lock held. A phase step can hold it for up to 3 s while it
> waits for the previous one. A dpll callback of that channel waits for
> the lock under dpll_lock, and every other DPLL request and notification
> in the system waits behind it. With ToD writes running, requests to an
> ice DPLL took 1448 ms in median and 3.9 s at most. With the series they
> took 0.2 ms and 0.3 ms, the same as idle.
> 
> The bigger reason are zl3073x callbacks we are working on, which have
> to wait for the hardware themselves:
> 
> - a device reset with resync waits for the fast lock, up to 1 s with a
>    1 PPS input
> - a glitchless stop or start of an output completes on an output edge,
>    so it takes up to one period, 1 s for a 1 PPS output
> 
> Holding the global dpll_lock for that long would stall every DPLL
> device in the system. For the output state we tried an asynchronous
> implementation, but then the callback returns success before it knows
> the result. 

Right, for these level of waiting async seems like the right direction,
at least naively/without knowing the HW.  Why does the device wait until
PPS to apply the step change? Is the programmed time supposed to
correspond to the pulse?

> A failure can only be reported by a later notification, and
> the next request gets -EBUSY until the change completes. With a lock
> per chip the callback can simply wait, and one chip cannot do these
> operations in parallel anyway.

Do the failures only happen because of "unforeseen circumstances" / EIO,
or there may be more common errors reported? If it's just the former
a devlink health reporter could be an option.
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Ivan Vecera 4 days, 16 hours ago
On 11/19/26 02:44, Jakub Kicinski wrote:
> On Wed, 18 Nov 2026 16:29:23 +0100 Ivan Vecera wrote:
>> A step of the zl3073x PHC, which ptp4l and ts2phc do at start and after
>> a large offset, waits for the next 1 PPS edge, up to 1 s, with the
>> channel lock held. A phase step can hold it for up to 3 s while it
>> waits for the previous one. A dpll callback of that channel waits for
>> the lock under dpll_lock, and every other DPLL request and notification
>> in the system waits behind it. With ToD writes running, requests to an
>> ice DPLL took 1448 ms in median and 3.9 s at most. With the series they
>> took 0.2 ms and 0.3 ms, the same as idle.
>>
>> The bigger reason are zl3073x callbacks we are working on, which have
>> to wait for the hardware themselves:
>>
>> - a device reset with resync waits for the fast lock, up to 1 s with a
>>     1 PPS input
>> - a glitchless stop or start of an output completes on an output edge,
>>     so it takes up to one period, 1 s for a 1 PPS output
>>
>> Holding the global dpll_lock for that long would stall every DPLL
>> device in the system. For the output state we tried an asynchronous
>> implementation, but then the callback returns success before it knows
>> the result.
> 
> Right, for these level of waiting async seems like the right direction,
> at least naively/without knowing the HW.  Why does the device wait until
> PPS to apply the step change? Is the programmed time supposed to
> correspond to the pulse?

Yes. The device has no immediate ToD write, it can only write the ToD
on the next internal 1 Hz edge, the next input sync edge or the next
internal 0.5 Hz edge. The written value is the time at that edge, so
the seconds stay aligned with the 1 PPS outputs.

Looking at it again, the zl3073x holds the channel lock while it waits
for the edge, although the dpll callbacks do not touch the ToD, TIE or
phase step registers, and they already run while the device applies
such an operation, because the PTP ops return right after issuing it.
I will look at narrowing the lock in the driver.

For the resync, async is not only about reporting the result. Fast lock
is a setting of the DPLL, not of a reference, and forcing it makes the
DPLL ignore its frequency and phase error monitors. While an
asynchronous resync is pending, everything else done to the DPLL runs
in forced fast lock. A reference switch, whether from a priority or
state change, a manual reference or the device itself in automatic
mode, would follow the fast lock phase rate instead of the configured
phase slope limit, and the resync would then report success on another
reference. A switch to NCO would keep the force bit set until the work
clears it. So every request changing the DPLL configuration would have
to fail with -EBUSY, cancel the resync, or wait for it. With a lock per
chip they simply wait, for at most 1 s.

>> A failure can only be reported by a later notification, and
>> the next request gets -EBUSY until the change completes. With a lock
>> per chip the callback can simply wait, and one chip cannot do these
>> operations in parallel anyway.
> 
> Do the failures only happen because of "unforeseen circumstances" / EIO,
> or there may be more common errors reported? If it's just the former
> a devlink health reporter could be an option.

For the output start and stop, only EIO. The device does not report a
stopped output and the driver can only wait for one period, so a health
reporter would work there.


For the resync, no. The wait ends with -ETIMEDOUT when the DPLL does
not enter fast lock, for example because the selected reference lost
its qualification in the meantime. That is a result of the input
signal the user needs in the reply, not a device fault.

Beyond the zl3073x, with the global lock any callback that waits for
its device, for example an mlx5 firmware command with its 60 s timeout,
stalls the DPLL devices of every other driver in the system.

Thanks,
Ivan
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Jakub Kicinski 4 days, 6 hours ago
On Thu, 19 Nov 2026 13:29:11 +0100 Ivan Vecera wrote:
> > Right, for these level of waiting async seems like the right direction,
> > at least naively/without knowing the HW.  Why does the device wait until
> > PPS to apply the step change? Is the programmed time supposed to
> > correspond to the pulse?  
> 
> Yes. The device has no immediate ToD write, it can only write the ToD
> on the next internal 1 Hz edge, the next input sync edge or the next
> internal 0.5 Hz edge. The written value is the time at that edge, so
> the seconds stay aligned with the 1 PPS outputs.
> 
> Looking at it again, the zl3073x holds the channel lock while it waits
> for the edge, although the dpll callbacks do not touch the ToD, TIE or
> phase step registers, and they already run while the device applies
> such an operation, because the PTP ops return right after issuing it.
> I will look at narrowing the lock in the driver.
> 
> For the resync, async is not only about reporting the result. Fast lock
> is a setting of the DPLL, not of a reference, and forcing it makes the
> DPLL ignore its frequency and phase error monitors. While an
> asynchronous resync is pending, everything else done to the DPLL runs
> in forced fast lock. A reference switch, whether from a priority or
> state change, a manual reference or the device itself in automatic
> mode, would follow the fast lock phase rate instead of the configured
> phase slope limit, and the resync would then report success on another
> reference. A switch to NCO would keep the force bit set until the work
> clears it. So every request changing the DPLL configuration would have
> to fail with -EBUSY, cancel the resync, or wait for it. With a lock per
> chip they simply wait, for at most 1 s.
> 
> > Do the failures only happen because of "unforeseen circumstances" / EIO,
> > or there may be more common errors reported? If it's just the former
> > a devlink health reporter could be an option.  
> 
> For the output start and stop, only EIO. The device does not report a
> stopped output and the driver can only wait for one period, so a health
> reporter would work there.
> 
> 
> For the resync, no. The wait ends with -ETIMEDOUT when the DPLL does
> not enter fast lock, for example because the selected reference lost
> its qualification in the meantime. That is a result of the input
> signal the user needs in the reply, not a device fault.
> 
> Beyond the zl3073x, with the global lock any callback that waits for
> its device, for example an mlx5 firmware command with its 60 s timeout,
> stalls the DPLL devices of every other driver in the system.

Well, I'm not convinced. The relations between objects in DPLL are
already quite hard to follow, and objects from one driver routinely
"plug" into objects from another. The explanation of the locking
rules in patch 9 does not look clean or clear. The driver facing
API needs to be much more "dummy-proof".
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Ivan Vecera 3 days, 20 hours ago
On 11/19/26 22:38, Jakub Kicinski wrote:
> Well, I'm not convinced. The relations between objects in DPLL are
> already quite hard to follow, and objects from one driver routinely
> "plug" into objects from another. The explanation of the locking
> rules in patch 9 does not look clean or clear. The driver facing
> API needs to be much more "dummy-proof".

Fair enough. The complicated part of the rules comes exactly from
that: a pin registered by another driver, like the zl3073x pins that
ice registers with its TXC DPLL or uses as parents of its RCLK pins.
A message about such a pin runs callbacks of both drivers. I have
prototypes of the first four ways below to lock this, each with KUnit
tests, and would like your opinion before going further.

In all of them a domain is the set of objects created with the same
module and clock_id, dpll_lock becomes an rwsem for the topology and
lifetime, and a mutex per domain serializes the callbacks.

A) Pin's domain (this series)

    Callbacks of a pin run under the domain of the pin, whichever
    driver registered them.

    Pros:
    * one domain lock at a time, so no lock order
    * a request or a message about a pin is atomic
    Cons:
    * the callbacks of a foreign pin are serialized with the driver
      that created the pin, not with the other callbacks of the driver
      that registered it, so that driver has to protect the shared
      state itself, and lockdep cannot check it
    * restrictions for measured_freq_get, reference sync pairs and the
      private data of a parent pin, which patch 9 has to explain

B) Registrant's domain, deferred notifications

    Each callback runs under the domain of the driver that registered
    it. A message about a pin takes the domain locks one after another,
    and notifications from callbacks are queued and sent once the
    domain lock is dropped.

    Pros:
    * callbacks registered by one driver instance are always
      serialized with each other
    * one domain lock at a time, so no lock order
    Cons:
    * a request or a message about a pin registered across domains is
      not atomic
    * the most complex core: a notification queue per domain, a lock
      per object to keep its messages in order, and pin setters split
      into validation and apply parts

C) Registrant's domain nested under the pin's domain

    Pros:
    * callbacks registered by one driver instance are serialized with
      each other and with the driver that created the pin
    * a request or a message about a pin is atomic
    Cons:
    * the lock order comes from the topology, so a pin of A registered
      with a DPLL of B together with a pin of B registered with a DPLL
      of A deadlocks, and lockdep sees it only with a lockdep class per
      domain
    * a stuck foreign registrant stops the domain of the pin

D) Merged domains (your suggestion)

    Registering a pin with a DPLL or a parent pin of another domain
    merges both domains. They are not split again.

    Pros:
    * the rules for drivers stay as they are with the global lock
      today, and lockdep checks them; the only new one is that state
      shared between chips not connected by a pin needs a driver lock
    * a request or a message is atomic
    Cons:
    * only hardware not connected by pins runs in parallel; on the
      GNR-D system the zl3073x and all ice PFs end up in one domain
    * a callback that waits for the hardware, like the planned resync
      for up to 1 s, or for firmware still stalls all DPLL devices in
      the merged domain

E) Global dpll_lock, slow callbacks asynchronous

    Pros:
    * no change in the core
    Cons:
    * the resync problems from my previous mail, and a callback that
      waits for firmware still stalls all DPLL devices in the system

I wrote before that stretching the domains would not improve
anything on that system. That holds for the ToD stall I measured,
but the zl3073x does not need to hold its channel lock across the
edge waits. Without that, the remaining waits are the planned resync
and output state callbacks, and with D they stall only the devices
wired to that chip, which depend on it anyway.

So I lean towards D, as it gives drivers nothing new to get right.
Would that address your concern, or do you see a better way?

It would be good to hear from the other DPLL maintainers as well.
Jiri, Vadim, Arkadiusz, what do you think?

Thanks,
Ivan
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Vadim Fedorenko 3 days, 8 hours ago
On 20/11/2026 07:39, Ivan Vecera wrote:
> On 11/19/26 22:38, Jakub Kicinski wrote:
>> Well, I'm not convinced. The relations between objects in DPLL are
>> already quite hard to follow, and objects from one driver routinely
>> "plug" into objects from another. The explanation of the locking
>> rules in patch 9 does not look clean or clear. The driver facing
>> API needs to be much more "dummy-proof".
> 
> Fair enough. The complicated part of the rules comes exactly from
> that: a pin registered by another driver, like the zl3073x pins that
> ice registers with its TXC DPLL or uses as parents of its RCLK pins.
> A message about such a pin runs callbacks of both drivers. I have
> prototypes of the first four ways below to lock this, each with KUnit
> tests, and would like your opinion before going further.
> 
> In all of them a domain is the set of objects created with the same
> module and clock_id, dpll_lock becomes an rwsem for the topology and
> lifetime, and a mutex per domain serializes the callbacks.
> 
> A) Pin's domain (this series)
> 
>     Callbacks of a pin run under the domain of the pin, whichever
>     driver registered them.
> 
>     Pros:
>     * one domain lock at a time, so no lock order
>     * a request or a message about a pin is atomic
>     Cons:
>     * the callbacks of a foreign pin are serialized with the driver
>       that created the pin, not with the other callbacks of the driver
>       that registered it, so that driver has to protect the shared
>       state itself, and lockdep cannot check it
>     * restrictions for measured_freq_get, reference sync pairs and the
>       private data of a parent pin, which patch 9 has to explain
> 
> B) Registrant's domain, deferred notifications
> 
>     Each callback runs under the domain of the driver that registered
>     it. A message about a pin takes the domain locks one after another,
>     and notifications from callbacks are queued and sent once the
>     domain lock is dropped.
> 
>     Pros:
>     * callbacks registered by one driver instance are always
>       serialized with each other
>     * one domain lock at a time, so no lock order
>     Cons:
>     * a request or a message about a pin registered across domains is
>       not atomic
>     * the most complex core: a notification queue per domain, a lock
>       per object to keep its messages in order, and pin setters split
>       into validation and apply parts
> 
> C) Registrant's domain nested under the pin's domain
> 
>     Pros:
>     * callbacks registered by one driver instance are serialized with
>       each other and with the driver that created the pin
>     * a request or a message about a pin is atomic
>     Cons:
>     * the lock order comes from the topology, so a pin of A registered
>       with a DPLL of B together with a pin of B registered with a DPLL
>       of A deadlocks, and lockdep sees it only with a lockdep class per
>       domain
>     * a stuck foreign registrant stops the domain of the pin
> 
> D) Merged domains (your suggestion)
> 
>     Registering a pin with a DPLL or a parent pin of another domain
>     merges both domains. They are not split again.
> 
>     Pros:
>     * the rules for drivers stay as they are with the global lock
>       today, and lockdep checks them; the only new one is that state
>       shared between chips not connected by a pin needs a driver lock
>     * a request or a message is atomic
>     Cons:
>     * only hardware not connected by pins runs in parallel; on the
>       GNR-D system the zl3073x and all ice PFs end up in one domain
>     * a callback that waits for the hardware, like the planned resync
>       for up to 1 s, or for firmware still stalls all DPLL devices in
>       the merged domain
> 
> E) Global dpll_lock, slow callbacks asynchronous
> 
>     Pros:
>     * no change in the core
>     Cons:
>     * the resync problems from my previous mail, and a callback that
>       waits for firmware still stalls all DPLL devices in the system
> 
> I wrote before that stretching the domains would not improve
> anything on that system. That holds for the ToD stall I measured,
> but the zl3073x does not need to hold its channel lock across the
> edge waits. Without that, the remaining waits are the planned resync
> and output state callbacks, and with D they stall only the devices
> wired to that chip, which depend on it anyway.
> 
> So I lean towards D, as it gives drivers nothing new to get right.
> Would that address your concern, or do you see a better way?
> 
> It would be good to hear from the other DPLL maintainers as well.
> Jiri, Vadim, Arkadiusz, what do you think?

I totally agree with Jakub. Current implementation of DPLL subsystem is
over complicated, and all these complications came just to completely
model what was designed for Intel NICs, basically ice driver. But now we
are again back to the discussion how to complicate things further just
to fit what was implemented in the new generation of the same hardware.

Maybe it's time to step back and think if we really need all this, or
find simpler way to express/model things?
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Jiri Pirko 1 day, 12 hours ago
Fri, Nov 20, 2026 at 09:00:27PM +0100, vadim.fedorenko@linux.dev wrote:
>On 20/11/2026 07:39, Ivan Vecera wrote:
>> On 11/19/26 22:38, Jakub Kicinski wrote:
>> > Well, I'm not convinced. The relations between objects in DPLL are
>> > already quite hard to follow, and objects from one driver routinely
>> > "plug" into objects from another. The explanation of the locking
>> > rules in patch 9 does not look clean or clear. The driver facing
>> > API needs to be much more "dummy-proof".
>> 
>> Fair enough. The complicated part of the rules comes exactly from
>> that: a pin registered by another driver, like the zl3073x pins that
>> ice registers with its TXC DPLL or uses as parents of its RCLK pins.
>> A message about such a pin runs callbacks of both drivers. I have
>> prototypes of the first four ways below to lock this, each with KUnit
>> tests, and would like your opinion before going further.
>> 
>> In all of them a domain is the set of objects created with the same
>> module and clock_id, dpll_lock becomes an rwsem for the topology and
>> lifetime, and a mutex per domain serializes the callbacks.
>> 
>> A) Pin's domain (this series)
>> 
>>     Callbacks of a pin run under the domain of the pin, whichever
>>     driver registered them.
>> 
>>     Pros:
>>     * one domain lock at a time, so no lock order
>>     * a request or a message about a pin is atomic
>>     Cons:
>>     * the callbacks of a foreign pin are serialized with the driver
>>       that created the pin, not with the other callbacks of the driver
>>       that registered it, so that driver has to protect the shared
>>       state itself, and lockdep cannot check it
>>     * restrictions for measured_freq_get, reference sync pairs and the
>>       private data of a parent pin, which patch 9 has to explain
>> 
>> B) Registrant's domain, deferred notifications
>> 
>>     Each callback runs under the domain of the driver that registered
>>     it. A message about a pin takes the domain locks one after another,
>>     and notifications from callbacks are queued and sent once the
>>     domain lock is dropped.
>> 
>>     Pros:
>>     * callbacks registered by one driver instance are always
>>       serialized with each other
>>     * one domain lock at a time, so no lock order
>>     Cons:
>>     * a request or a message about a pin registered across domains is
>>       not atomic
>>     * the most complex core: a notification queue per domain, a lock
>>       per object to keep its messages in order, and pin setters split
>>       into validation and apply parts
>> 
>> C) Registrant's domain nested under the pin's domain
>> 
>>     Pros:
>>     * callbacks registered by one driver instance are serialized with
>>       each other and with the driver that created the pin
>>     * a request or a message about a pin is atomic
>>     Cons:
>>     * the lock order comes from the topology, so a pin of A registered
>>       with a DPLL of B together with a pin of B registered with a DPLL
>>       of A deadlocks, and lockdep sees it only with a lockdep class per
>>       domain
>>     * a stuck foreign registrant stops the domain of the pin
>> 
>> D) Merged domains (your suggestion)
>> 
>>     Registering a pin with a DPLL or a parent pin of another domain
>>     merges both domains. They are not split again.
>> 
>>     Pros:
>>     * the rules for drivers stay as they are with the global lock
>>       today, and lockdep checks them; the only new one is that state
>>       shared between chips not connected by a pin needs a driver lock
>>     * a request or a message is atomic
>>     Cons:
>>     * only hardware not connected by pins runs in parallel; on the
>>       GNR-D system the zl3073x and all ice PFs end up in one domain
>>     * a callback that waits for the hardware, like the planned resync
>>       for up to 1 s, or for firmware still stalls all DPLL devices in
>>       the merged domain
>> 
>> E) Global dpll_lock, slow callbacks asynchronous
>> 
>>     Pros:
>>     * no change in the core
>>     Cons:
>>     * the resync problems from my previous mail, and a callback that
>>       waits for firmware still stalls all DPLL devices in the system
>> 
>> I wrote before that stretching the domains would not improve
>> anything on that system. That holds for the ToD stall I measured,
>> but the zl3073x does not need to hold its channel lock across the
>> edge waits. Without that, the remaining waits are the planned resync
>> and output state callbacks, and with D they stall only the devices
>> wired to that chip, which depend on it anyway.
>> 
>> So I lean towards D, as it gives drivers nothing new to get right.
>> Would that address your concern, or do you see a better way?
>> 
>> It would be good to hear from the other DPLL maintainers as well.
>> Jiri, Vadim, Arkadiusz, what do you think?
>
>I totally agree with Jakub. Current implementation of DPLL subsystem is
>over complicated, and all these complications came just to completely
>model what was designed for Intel NICs, basically ice driver. But now we
>are again back to the discussion how to complicate things further just
>to fit what was implemented in the new generation of the same hardware.
>
>Maybe it's time to step back and think if we really need all this, or
>find simpler way to express/model things?

Agreed.
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Ivan Vecera 1 week ago
Hi Jakub/Paolo,

v2 no longer applies to net-next since net was merged in. It conflicts
with 7a3837929d04 ("dpll: notify about a reference sync pair only if it
was added") in dpll_pin_ref_sync_pair_add(). Patches 3 and 4 fail on
the same lines and the rest applies cleanly. After patch 4 the
resolution is:

	down_write(&dpll_lock);
	ret = xa_insert(&pin->ref_sync_pins, ref_sync_pin->id,
			ref_sync_pin, GFP_KERNEL);
	if (!ret) {
		mutex_lock(&pin->domain->lock);
		__dpll_pin_change_ntf(pin);
		mutex_unlock(&pin->domain->lock);
	}
	up_write(&dpll_lock);

Patch 3 is the same, with mutex_lock() and mutex_unlock() of dpll_lock.
KUnit passes on the result. The SyncE CGU fix that the series needs [1]
is in net-next as well.

Sashiko found only low severity issues, I answered them in the replies
to patches 4, 8 and 9. Would you resolve the conflict when applying and
take the fixes of those issues as a follow-up, or do you prefer a v3
rebased on net-next with them fixed?

Thanks,
Ivan

[1] https://lore.kernel.org/netdev/20261110094350.184185-1-ivecera@redhat.com/
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Jakub Kicinski 1 week ago
On Mon, 16 Nov 2026 09:24:39 +0100 Ivan Vecera wrote:
> v2 no longer applies to net-next since net was merged in. It conflicts
> with 7a3837929d04 ("dpll: notify about a reference sync pair only if it
> was added") in dpll_pin_ref_sync_pair_add(). Patches 3 and 4 fail on
> the same lines and the rest applies cleanly. After patch 4 the
> resolution is:

What makes you think we'd rebase your patches for you?
-- 
pw-bot: cr
Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Posted by Ivan Vecera 5 days, 13 hours ago
On 11/17/26 03:17, Jakub Kicinski wrote:
> On Mon, 16 Nov 2026 09:24:39 +0100 Ivan Vecera wrote:
>> v2 no longer applies to net-next since net was merged in. It conflicts
>> with 7a3837929d04 ("dpll: notify about a reference sync pair only if it
>> was added") in dpll_pin_ref_sync_pair_add(). Patches 3 and 4 fail on
>> the same lines and the rest applies cleanly. After patch 4 the
>> resolution is:
> 
> What makes you think we'd rebase your patches for you?

Sorry, that came out wrong. I wanted to flag the conflict with the fix
from net, not to hand the rebase to you. I will send v3 rebased on
net-next once the questions in your other reply are settled.

Thanks,
Ivan