From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796225606; b=rcT1xAgI42VJqgPmK5W9Uk45mPQ+znVTOT7UNSGQcbcYdNhfNj4ywUaZelkxhFJAUFD9 zyg+xxDtWG5uduUSgD+Kzsqmtw4MSZ4/cD+Ri00jkQ7V4TMNU1/lZw5ASyNy+fFgAxKUf D9+IdcV9MzAAmqFJ/qwkmniYGSkCCwKKICsNwGBoVxbjTiogQG4h1GetGqdmhTDiCGiXd q3/Q8Pnr0dWUv1oYpScDHat4pHlPPFb8qOHiY14ZGKvGXnEEmSKxD5lxwIYiFqrbgtBt3 ySQqF3D0YTeMRVjP7V/vcsBKwgHrXjfNioIrqW/QeevdXmpyG46K40t82SEXhAtdhEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796225606; 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=wr85YSA8hVq2x45p4E8o18FF6RveCBYg/4Tgb9jWyKU=; b=glRIL2py+XVv/mMNw6f3EMNRpDWHhUfPAdD6pS11vnPejetaCgdnmfGEbOmkCcrfHp3c YYZh23lfmU5AlUy6EBufjhr43PmnUdPbusm0GK8/lBMY7qr3bos++bbqcg9iDrIc9pS9v 0WYeN/wXUfamdFLpBIh2b/mmL1vHutwOEc8Vzt7e2kq4ODsQuiPHn2YN7t1RhJCypiGnO sb9JQJXfFsfCeWFYI5QiFEV+VTlwORkZ/cP1xRCo9lBU5L2gGmYt665JD4MSekUQnqWUc rjbtM2CPvtzdcJpcqE9CfYq8Hwd/ev6nCspDy8mMpiosyRMBV/p2WAp7eNXnWdArtiQ== 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="UFG1/PL4"; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 F29C3606A327 for ; Wed, 2 Dec 2026 15:33:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F29C3606A327 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=UFG1/PL4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796225606; 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=wr85YSA8hVq2x45p4E8o18FF6RveCBYg/4Tgb9jWyKU=; b=UFG1/PL4pvBgzr0qIl77E2jtzSOj02vF+jUyZ+Tb3WGhY75BMjlLmLZHXWv8kV9bb2NHbq 0w29qq3au6qc/PYvHyCTZuiefvUKz0VozcYIzDik0cTqO3Dv+QHbMpsm+o6wPEgTzr2g+y PkRAM7aX3fOf3nPbtP6cYBa/WmwE38U= 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-517-vbUXd28pPUC6PnYbeMEBmQ-1; Wed, 2 Dec 2026 15:33:19 +0000 X-MC-Unique: vbUXd28pPUC6PnYbeMEBmQ-1 X-Mimecast-MFC-AGG-ID: vbUXd28pPUC6PnYbeMEBmQ_1796225597 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 196D9192E27D; Wed, 2 Dec 2026 15:33:17 +0000 (UTC) Received: from poros-thinkpadp16vgen1.tpbc.com (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 13E391801438; Wed, 2 Dec 2026 15:33:12 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: Petr Oros , Ivan Vecera , Jonathan Corbet , Shuah Khan , Shuah Khan , Randy Dunlap , Jani Nikula , Vadim Fedorenko , Arkadiusz Kubalewski , Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH net-next v6 09/14] dpll: dpllsim: Add support to set frequency on pins Date: Wed, 2 Dec 2026 16:32:18 +0100 Message-ID: <20261202153223.2725780-10-poros@redhat.com> In-Reply-To: <20261202153223.2725780-1-poros@redhat.com> References: <20261202153223.2725780-1-poros@redhat.com> X-Mailing-List: netdev@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.4.1 on 10.30.177.93 Add support to set the frequency of input and output pins. The DPLL core validates the requested value against the supported frequency list the pin advertises, so the frequency_set callback only has to store it. The same per type tables that validate the configured frequency at live time serve as the supported list. The configfs attribute is rejected with EBUSY while the device is live, so only the netlink setter changes the frequency of a registered pin and the two cannot race. The frequency set over netlink is kept apart from the configured one, like the priority, so the attribute keeps showing what was configured and every live transition starts from it. Reviewed-by: Ivan Vecera Signed-off-by: Petr Oros --- v6: - no change, carry the Reviewed-by given to v5 (Ivan Vecera) v5: - no changes v4: - keep the frequency set over netlink apart from the configured one, like the priority - document that values set over netlink are not written back to the attributes - the Reviewed-by and Acked-by of v3 are not carried over, the behaviour of the driver changed v5: https://lore.kernel.org/all/20261125090522.3777494-10-poros@redhat.com/ v4: https://lore.kernel.org/all/20261112130359.840795-10-poros@redhat.com/ v3: https://lore.kernel.org/all/20261109093523.931201-10-poros@redhat.com/ --- Documentation/driver-api/dpllsim.rst | 10 +++++----- drivers/dpll/dpllsim/core.c | 4 ++-- drivers/dpll/dpllsim/dpll.c | 20 ++++++++++++++++++-- drivers/dpll/dpllsim/dpllsim.h | 8 ++++++-- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Documentation/driver-api/dpllsim.rst b/Documentation/driver-api/dpllsim.rst index b50c8d4cb454e7..fd38f4c2ea19f1 100644 --- a/Documentation/driver-api/dpllsim.rst +++ b/Documentation/driver-api/dpllsim.rst @@ -68,11 +68,11 @@ priority other than the default, and with ``ENOENT`` when a pin directory is being created or removed at the same time. An ``EINVAL`` does not name the pin, the attributes of the pins show which one it is. -Every live transition starts from the configured values. A priority set -over netlink while the instance is live is reported back over netlink, -it is not written to the ``prio`` attribute and is gone once the -instance is taken down. The driver stores the priority, it does not -select a reference by it. +Every live transition starts from the configured values. A frequency or +a priority set over netlink while the instance is live is reported back +over netlink, it is not written to the ``frequency`` or ``prio`` +attribute and is gone once the instance is taken down. The driver +stores the priority, it does not select a reference by it. Example ======= diff --git a/drivers/dpll/dpllsim/core.c b/drivers/dpll/dpllsim/core.c index b292843fad4871..f90f7dfc168135 100644 --- a/drivers/dpll/dpllsim/core.c +++ b/drivers/dpll/dpllsim/core.c @@ -110,7 +110,7 @@ static ssize_t dpllsim_pin_frequency_show(struct config_item *item, char *page) struct dpllsim_pin *pin = to_dpllsim_pin(item); guard(mutex)(&pin->dev->lock); - return sysfs_emit(page, "%llu\n", pin->frequency); + return sysfs_emit(page, "%llu\n", pin->cfg_frequency); } static ssize_t dpllsim_pin_frequency_store(struct config_item *item, @@ -127,7 +127,7 @@ static ssize_t dpllsim_pin_frequency_store(struct config_item *item, guard(mutex)(&pin->dev->lock); if (dpllsim_dev_frozen(pin->dev)) return -EBUSY; - pin->frequency = val; + pin->cfg_frequency = val; return count; } CONFIGFS_ATTR(dpllsim_pin_, frequency); diff --git a/drivers/dpll/dpllsim/dpll.c b/drivers/dpll/dpllsim/dpll.c index 8f1806d0030f24..8900f2042f5539 100644 --- a/drivers/dpll/dpllsim/dpll.c +++ b/drivers/dpll/dpllsim/dpll.c @@ -79,6 +79,19 @@ static int dpllsim_pin_frequency_get(const struct dpll_pin *pin, return 0; } +static int dpllsim_pin_frequency_set(const struct dpll_pin *pin, + void *pin_priv, + const struct dpll_device *dpll, + void *dpll_priv, u64 frequency, + struct netlink_ext_ack *extack) +{ + struct dpllsim_pin *sim_pin = pin_priv; + + guard(mutex)(&sim_pin->dev->lock); + sim_pin->frequency = frequency; + return 0; +} + /* The direction is configuration, written by the configfs store only, * which is refused while the device is frozen. The callbacks run while * the pin is registered, which is inside the frozen window, so no @@ -176,6 +189,7 @@ static int dpllsim_pin_prio_set(const struct dpll_pin *pin, void *pin_priv, static const struct dpll_pin_ops dpllsim_input_pin_ops = { .frequency_get = dpllsim_pin_frequency_get, + .frequency_set = dpllsim_pin_frequency_set, .direction_get = dpllsim_pin_direction_get, .state_on_dpll_get = dpllsim_pin_state_get, .state_on_dpll_set = dpllsim_pin_state_set, @@ -185,6 +199,7 @@ static const struct dpll_pin_ops dpllsim_input_pin_ops = { static const struct dpll_pin_ops dpllsim_output_pin_ops = { .frequency_get = dpllsim_pin_frequency_get, + .frequency_set = dpllsim_pin_frequency_set, .direction_get = dpllsim_pin_direction_get, .state_on_dpll_get = dpllsim_pin_state_get, }; @@ -238,8 +253,8 @@ static bool dpllsim_pin_frequency_valid(struct dpllsim_pin *pin) dpllsim_pin_props(pin, &prop); for (i = 0; i < prop.freq_supported_num; i++) - if (pin->frequency >= prop.freq_supported[i].min && - pin->frequency <= prop.freq_supported[i].max) + if (pin->cfg_frequency >= prop.freq_supported[i].min && + pin->cfg_frequency <= prop.freq_supported[i].max) return true; return false; @@ -263,6 +278,7 @@ static void dpllsim_pin_reset(struct dpllsim_pin *pin) { pin->ops = dpllsim_pin_select_ops(pin); pin->state = DPLL_PIN_STATE_DISCONNECTED; + pin->frequency = pin->cfg_frequency; pin->prio = pin->cfg_prio; } diff --git a/drivers/dpll/dpllsim/dpllsim.h b/drivers/dpll/dpllsim/dpllsim.h index 398d5b50a40cab..f897969eb9ca69 100644 --- a/drivers/dpll/dpllsim/dpllsim.h +++ b/drivers/dpll/dpllsim/dpllsim.h @@ -27,7 +27,7 @@ struct dpllsim_pin { /* Configuration, writable only until dpllsim_dev_frozen() */ enum dpll_pin_type type; enum dpll_pin_direction direction; - u64 frequency; + u64 cfg_frequency; u32 cfg_prio; /* Resolved at live=1 */ @@ -39,7 +39,11 @@ struct dpllsim_pin { /* Simulated state, guarded by dev->lock */ enum dpll_pin_state state; - /* Starts from cfg_prio at live=1, changed by the netlink setter */ + /* + * Start from cfg_frequency and cfg_prio at live=1, changed by the + * netlink setters + */ + u64 frequency; u32 prio; }; -- 2.56.1