Netdev List
 help / color / mirror / Atom feed
From: Ivan Vecera <ivecera@redhat.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: netdev@vger.kernel.org,
	Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
	Jiri Pirko <jiri@resnulli.us>, Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Min Li <min.li@microchip.com>,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Richard Cochran <richardcochran@gmail.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org,
	Grzegorz Nitka <grzegorz.nitka@intel.com>,
	Karol Kolacinski <karol.kolacinski@intel.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>, Petr Oros <poros@redhat.com>
Subject: Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock
Date: Thu, 26 Nov 2026 13:30:57 +0100	[thread overview]
Message-ID: <851d61dc-7416-4b3f-85e7-8a30bc19fab8@redhat.com> (raw)
In-Reply-To: <20261126091510.7ac67b35@pumpkin>

On 11/26/26 10:15, David Laight wrote:
> On Wed, 11 Nov 2026 17:40:11 +0100
> Ivan Vecera <ivecera@redhat.com> 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.
>>
>> 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.
> 
> Isn't the big problem with callbacks handling deregistration?
> With a global lock there isn't a problem.
> But as soon as you do anything else you have to have very explicit
> rules to safely deregister a callback without either a UAF or an ABBA
> locking issue.
> 
> I don't see this being mentioned.
> 
> David
The cover only says that dpll_lock keeps protecting the object
lifetime, the details are in patches 4 and 9.

All unregister functions take dpll_lock for write. Netlink requests,
dumps and notifications hold it for read for their whole duration,
including the callbacks. So dpll_device_unregister(),
dpll_pin_unregister() and dpll_pin_on_pin_unregister() wait until the
running callbacks finish, and no new one can start, because objects
are looked up under the read lock. Once they return, the ops and the
private data of that registration are not used anymore. This is the
same as posix_clock_unregister() taking the rwsem of the clock for
write. A KUnit test in patch 5 checks that a function taking dpll_lock
for write waits for a running callback.

For ABBA the rules are the same as with the mutex today: a driver must
not call a function that takes dpll_lock, including the unregister
functions, while holding a lock that its callbacks take, and a
callback must not call one at all. Patch 9 documents both, and lockdep
reports a violation.

Thanks,
Ivan


      reply	other threads:[~2026-11-26 12:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 16:40 [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock Ivan Vecera
2026-11-11 16:40 ` [PATCH net-next v2 1/9] ice: dpll: notify TSPLL lock status from the periodic work only Ivan Vecera
2026-11-11 16:40 ` [PATCH net-next v2 2/9] dpll: add domain object Ivan Vecera
2026-11-11 16:40 ` [PATCH net-next v2 3/9] dpll: take domain locks around driver callbacks Ivan Vecera
2026-11-11 16:40 ` [PATCH net-next v2 4/9] dpll: convert dpll_lock to rwsem Ivan Vecera
2026-11-16  8:21   ` Ivan Vecera
2026-11-11 16:40 ` [PATCH net-next v2 5/9] dpll: add KUnit tests for core locking Ivan Vecera
2026-11-11 16:40 ` [PATCH net-next v2 6/9] dpll: reject measured_freq_get for foreign and on-pin registrations Ivan Vecera
2026-11-11 16:40 ` [PATCH net-next v2 7/9] dpll: zl3073x: update locking comments Ivan Vecera
2026-11-11 16:40 ` [PATCH net-next v2 8/9] ice: dpll: " Ivan Vecera
2026-11-16  8:22   ` Ivan Vecera
2026-11-11 16:40 ` [PATCH net-next v2 9/9] dpll: document locking rules Ivan Vecera
2026-11-16  8:23   ` Ivan Vecera
2026-11-16  8:24 ` [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock Ivan Vecera
2026-11-17  2:17   ` Jakub Kicinski
2026-11-18 15:30     ` Ivan Vecera
2026-11-17  2:16 ` Jakub Kicinski
2026-11-18 15:29   ` Ivan Vecera
2026-11-19  1:44     ` Jakub Kicinski
2026-11-19 12:29       ` Ivan Vecera
2026-11-19 21:38         ` Jakub Kicinski
2026-11-20  7:39           ` Ivan Vecera
2026-11-20 20:00             ` Vadim Fedorenko
2026-11-22 15:54               ` Jiri Pirko
2026-11-25 14:31                 ` Ivan Vecera
2026-11-25 15:56                   ` Kubalewski, Arkadiusz
2026-11-25 16:41                     ` Ivan Vecera
2026-11-25 15:46             ` Kubalewski, Arkadiusz
2026-11-25 15:36         ` Kubalewski, Arkadiusz
2026-11-25 16:27           ` Ivan Vecera
2026-11-26  9:15 ` David Laight
2026-11-26 12:30   ` Ivan Vecera [this message]

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=851d61dc-7416-4b3f-85e7-8a30bc19fab8@redhat.com \
    --to=ivecera@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=david.laight.linux@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=grzegorz.nitka@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jiri@resnulli.us \
    --cc=karol.kolacinski@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=min.li@microchip.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=poros@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rdunlap@infradead.org \
    --cc=richardcochran@gmail.com \
    --cc=saeedm@nvidia.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tariqt@nvidia.com \
    --cc=vadim.fedorenko@linux.dev \
    /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