dpll: do not serialize driver callbacks under global dpll_lock
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest9 patches 14 repliesIn review
- v110 patches 19 repliesSuperseded
Changes in v2 from the cover letter
- 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
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | ice: dpll: notify TSPLL lock status from the periodic work onlydrivers/ | +6 | 0 replies | |
| 2/9 | dpll: add domain objectdrivers/ drivers/ | +85 | 0 replies | |
| 3/9 | dpll: take domain locks around driver callbacksdrivers/ drivers/ drivers/ | +85 | 0 replies | |
| 4/9 | dpll: convert dpll_lock to rwsemdrivers/ drivers/ drivers/ | +63 | 1 reply | |
| 5/9 | dpll: add KUnit tests for core lockingdrivers/ drivers/ drivers/ +2 more | +1504 | 0 replies | |
| 6/9 | dpll: reject measured_freq_get for foreign and on-pin registrationsdrivers/ drivers/ | +111 | 0 replies | |
| 7/9 | dpll: zl3073x: update locking commentsdrivers/ | +5 | 0 replies | |
| 8/9 | ice: dpll: update locking commentsdrivers/ drivers/ | +7 | 1 reply | |
| 9/9 | dpll: document locking rulesDocumentation/ drivers/ | +61 | 1 reply |
Reviews trailers per patch
All 9 patches have a Reviewed-by or Acked-by.
| Patch | Petr Oros |
|---|---|
| 1/9 | R-b |
| 2/9 | R-b |
| 3/9 | R-b |
| 4/9 | R-b |
| 5/9 | R-b |
| 6/9 | R-b |
| 7/9 | R-b |
| 8/9 | R-b |
| 9/9 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
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/[email protected]/
[1] https://lore.kernel.org/netdev/[email protected]/
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
Signature · 1 line
2.56.0