From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794415292; b=ixVH6IO9yw5PhM0DhpsYS+5gQi4K8CD2YQwVI8ceseP20+PlpeEf6FlI+LUm3E7/p5i2 7HUIa/KZS1BhE4szmp7pmhuSmXz+bv7GthmP+Jv6SZqBJz8XTOYPBwvXJ/R95iGhuv0Nz ivq4+nGHyXGRR4Dg6DN3bJP7Fhm8K+kTtCH9bXaI4l9Qe1tKaAFpwhPg82znHEpxihLqR BZ3u9++6b62xZ4wn+MKvdOTIU2V1oRWbTukpTuvommtgzzBHQs4BVPCNq0yZk3xtnKo/I kvt9do7tQiYbWDwbwOnrhK165iDKoCK5pdQwwz6QqGrRsTph3ek6regV+xP1+yS/m/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794415292; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=TC/qzi0GwbwJRPe4iytsw8ARC/xSRyQXvSanD2vms5g=; b=jeTra4VhpLRW0JzpIsbMSNh+goqaxq4krKOipRms4WqGTsCnIfhURhIalXiViNH0s+7w 5lv9vPyUCknU4HBDPiWeVKbf8rh1EMri9f98PxTOA9Pq8KBjMCWP9Wv7cEPM9wRrVd1et KG52C3TvG4FqFPI+X4v15MjT1DW74l3jWfUbgMBeb67acCFNgCZHUQ82UNIZyKVsRVpch lqmQF4ngHCRGmQYOaGZRoEhdXgWqxLqR8Olq4cHeDL2wZF8HWTrSe6mDk8bn7+f3GnAPF QJVYV6O0qzm3cksQ94d5ExvTYY+cMp7hvAnqYGRqoM6F89vrHCUswukUG08sBlytD3w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ViYp3FRw; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8047E60A2606 for ; Wed, 11 Nov 2026 16:41:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8047E60A2606 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ViYp3FRw DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794415290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TC/qzi0GwbwJRPe4iytsw8ARC/xSRyQXvSanD2vms5g=; b=ViYp3FRwmH1jz3kkbUNp8AiQMotf/rta8pnIwVaEXdEZNlb7394jAEOjDWP/1mdT29Vxa7 6r81+yNdDajcd+MDBxeRZwOnHvk4gr6SvljEM+ev2kwU87exvPdXaN9RkipbRS2X6yf5S3 Vu88h4Jc9QZy6RZQSKUkt28W+il1Bfc= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-QeALwB0-N6OvZSh1l3qmTg-1; Wed, 11 Nov 2026 11:41:27 -0500 X-MC-Unique: QeALwB0-N6OvZSh1l3qmTg-1 X-Mimecast-MFC-AGG-ID: QeALwB0-N6OvZSh1l3qmTg_1794415284 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 337721955DE4; Wed, 11 Nov 2026 16:41:24 +0000 (UTC) Received: from ivecera-thinkpadp16vgen1.tpbc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 47E5A410; Wed, 11 Nov 2026 16:41:18 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Vadim Fedorenko , Arkadiusz Kubalewski , Jiri Pirko , Jonathan Corbet , Shuah Khan , Randy Dunlap , Min Li , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Grzegorz Nitka , Karol Kolacinski , Saeed Mahameed , Tariq Toukan , Petr Oros Subject: [PATCH net-next v2 9/9] dpll: document locking rules Date: Wed, 11 Nov 2026 17:40:20 +0100 Message-ID: <20261111164021.273409-10-ivecera@redhat.com> In-Reply-To: <20261111164021.273409-1-ivecera@redhat.com> References: <20261111164021.273409-1-ivecera@redhat.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Describe the lock levels of the subsystem, which domain a callback runs under and the rules device drivers have to follow. Reviewed-by: Petr Oros Signed-off-by: Ivan Vecera --- Changes in v2: - Added a rule for reference sync pairs (Sashiko) - Rules 1 and 3 also forbid waiting for a work item that notifies (Sashiko) --- Documentation/driver-api/dpll.rst | 48 +++++++++++++++++++++++++++++++ drivers/dpll/dpll_core.c | 13 +++++++++ 2 files changed, 61 insertions(+) diff --git a/Documentation/driver-api/dpll.rst b/Documentation/driver-api/dpll.rst index 7c117ae37cc1bc..9cc6a912c58913 100644 --- a/Documentation/driver-api/dpll.rst +++ b/Documentation/driver-api/dpll.rst @@ -675,6 +675,54 @@ In the error path we have to rewind every allocation in the reverse order: More complex example can be found in Intel's ICE driver or nVidia's mlx5 driver. +Locking +======= + +The subsystem uses two levels of locks, always taken in this order: + +- ``dpll_lock`` protects the topology of dpll devices and pins and their + lifetime. Functions changing the topology, for example dpll_pin_register(), + take it for write and send the create and delete notifications under it. + Netlink requests, each part of a dump and change notifications take it for + read for their whole duration. +- A domain lock serializes driver callbacks. All dpll devices and pins created + with the same module and ``clock_id`` belong to one domain, in practice to + one chip or card. + +A netlink request addressing a device or a pin by its ID holds the domain lock +of that object from start to end. A notification holds it while its message is +built and sent, so messages of one object are sent in the order they were +built. Only one domain lock is held at a time, so domains have no lock order, +and callbacks of different domains can run concurrently. + +Callbacks of a dpll device run under the domain of the device. Callbacks of a +pin run under the domain of the pin, whichever driver registered them: + +- A driver registering a pin of another driver with its dpll device has these + callbacks serialized with the driver that created the pin, not with the other + callbacks of its device, so it has to protect the state they share by itself. + A callback stuck in such a registration stops the domain of the pin. +- The parent pin of a pin registered with dpll_pin_on_pin_register() and its + dpll devices can belong to another driver, so the callback must not + dereference their private data. +- The frequency monitor belongs to the dpll device, so only callbacks of a pin + of the same domain registered with dpll_pin_register() can include + ``.measured_freq_get``. +- The reference sync callbacks of a pin get the private data of the other pin + of the pair, so both pins of a pair added by dpll_pin_ref_sync_pair_add() + have to belong to one domain. + +Device drivers have to follow these rules: + +- A callback must not call dpll_device_change_ntf(), dpll_pin_change_ntf() or + any function changing the topology, nor wait for a work item that calls them. +- A callback notifies about objects of the domain it runs under with + __dpll_device_change_ntf() or __dpll_pin_change_ntf(). Other objects have to + be notified from a context that holds no domain lock, for example a work item. +- A driver must not call dpll_device_change_ntf(), dpll_pin_change_ntf() or any + function changing the topology, nor wait for a work item that calls them, + while holding a lock that its callbacks take. + SyncE enablement ================ For SyncE enablement it is required to allow control over dpll device diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c index a73abb0772cc6b..9a0843bba184af 100644 --- a/drivers/dpll/dpll_core.c +++ b/drivers/dpll/dpll_core.c @@ -932,6 +932,10 @@ __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin, * @ops: ops for a dpll pin ops * @priv: pointer to private information of owner * + * The callbacks run under the domain of @pin. If @pin belongs to another domain + * than @dpll, they are not serialized with the callbacks of @dpll and @ops must + * not include .measured_freq_get. + * * Context: Acquires dpll_lock and domain locks * Return: * * 0 on success @@ -1049,6 +1053,11 @@ EXPORT_SYMBOL_GPL(dpll_pin_unregister); * Register a pin with a parent pin, create references between them and * between newly registered pin and dplls connected with a parent pin. * + * The callbacks run under the domain of @pin. The parent pin and its dplls can + * belong to another driver, so @ops must not dereference their private data. + * The frequency monitor belongs to a dpll, so @ops must not include + * .measured_freq_get. + * * Context: Acquires dpll_lock and domain locks * Return: * * 0 on success @@ -1137,6 +1146,10 @@ EXPORT_SYMBOL_GPL(dpll_pin_on_pin_unregister); * * Once pins are paired, the user-space configuration of reference sync pair * is possible. + * + * The reference sync callbacks of each pin get the private data of the other + * one, so both pins must belong to one domain. + * * Context: Acquires dpll_lock and domain locks * Return: * * 0 on success -- 2.56.0