From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 842A4E81DE9 for ; Fri, 6 Oct 2023 11:44:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 3ECA960FB9; Fri, 6 Oct 2023 11:44:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 3ECA960FB9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1696592656; bh=Z8xev54yocih9tBWAjlZAU+cwis4FEEMiXrrOr6SikE=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=kum0SD8ohG2Erw2YE1hdOhBqSg49XYhTyXSQCErct6ww8Qm45L+8/VXAkxZR3cL8o HjmPpkWwt4vwF6QQuGWSU3Ff8/pYkIvYh03ZUNvgce0fcBl4mrXH0UdC8sMhIF43qM Aj7sm0WgXqCslKaO/0laAo3YfsdEkkKW4VWla/9ZPu/pXDf7Hon9vrhqkybKcCY0iq G2d9Z/Xg10q+H9zMic7OaC0UMGtsl4jI6dkHGooqbJ9fFCe5se3Z7EY8BnSAZKH4Iq dJ4rbP/FHTqwhOUToxLRhcID090YmU5qGAFFzEKAE4WFOrCIddhQWPiC28vrpNA8ST x5HcXOC/eFYkA== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XV6M2vHUQXXu; Fri, 6 Oct 2023 11:44:15 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 52E0E61234; Fri, 6 Oct 2023 11:44:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 52E0E61234 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 6FDAD1BF4E3 for ; Fri, 6 Oct 2023 11:44:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5642383B6F for ; Fri, 6 Oct 2023 11:44:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 5642383B6F X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XZvGQRWy_XSI for ; Fri, 6 Oct 2023 11:44:03 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by smtp1.osuosl.org (Postfix) with ESMTPS id 2995883B5E for ; Fri, 6 Oct 2023 11:44:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2995883B5E X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="470003284" X-IronPort-AV: E=Sophos;i="6.03,204,1694761200"; d="scan'208";a="470003284" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2023 04:44:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="925942728" X-IronPort-AV: E=Sophos;i="6.03,204,1694761200"; d="scan'208";a="925942728" Received: from amlin-018-114.igk.intel.com ([10.102.18.114]) by orsmga005.jf.intel.com with ESMTP; 06 Oct 2023 04:43:59 -0700 From: Arkadiusz Kubalewski To: netdev@vger.kernel.org Date: Fri, 6 Oct 2023 13:41:01 +0200 Message-Id: <20231006114101.1608796-6-arkadiusz.kubalewski@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20231006114101.1608796-1-arkadiusz.kubalewski@intel.com> References: <20231006114101.1608796-1-arkadiusz.kubalewski@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696592643; x=1728128643; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T7B4f7810U0FdBKSEAXDN5xAeXxcWlTekOw+2N8jEHU=; b=ezo48cd7qgJ9ubG1HyLzy+WVZcxE8LdvHYZU2Uf5nN+acNxb5l6uUK6f TlerphNxrThgeWZUiK91kubrqPrAaMSO6L8m5TixtUadYLanU29srPwrb tuNSpzdBL0C94vW2TGkMNSECKsKDk2YZgKZ7O3/15dO1zClaNMx4doBjE +13cDiMBfozpuw6x4pbjgtKwBP5XQuGFb6wxrSqurNZgIhawb5J8SamBL PTc5hiY4SrGBROALJ491/4amLQ80bGOeTmD8wiMI+gdrms/wBbWZkjJG1 CKdRlrAO+DrL0OG5FOjWXXAa+VxI03xbb9rF5D/kzbRHyYnuXiQBBes58 g==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ezo48cd7 Subject: [Intel-wired-lan] [PATCH net-next v3 5/5] dpll: netlink/core: change pin frequency set behavior X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiri@resnulli.us, corbet@lwn.net, intel-wired-lan@lists.osuosl.org, linux-doc@vger.kernel.org, jesse.brandeburg@intel.com, Arkadiusz Kubalewski , anthony.l.nguyen@intel.com, kuba@kernel.org, vadim.fedorenko@linux.dev, pabeni@redhat.com, davem@davemloft.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Align the aproach of pin frequency set behavior with the approach introduced with pin phase adjust set. Fail the request if any of devices did not registered the callback ops. If callback op on any pin's registered device fails, return error and rollback the value to previous one. Signed-off-by: Arkadiusz Kubalewski --- drivers/dpll/dpll_netlink.c | 50 +++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c index 97319a9e4667..8e5fea74aec1 100644 --- a/drivers/dpll/dpll_netlink.c +++ b/drivers/dpll/dpll_netlink.c @@ -615,30 +615,60 @@ static int dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a, struct netlink_ext_ack *extack) { - u64 freq = nla_get_u64(a); - struct dpll_pin_ref *ref; + u64 freq = nla_get_u64(a), old_freq; + struct dpll_pin_ref *ref, *failed; + const struct dpll_pin_ops *ops; + struct dpll_device *dpll; unsigned long i; int ret; if (!dpll_pin_is_freq_supported(pin, freq)) { - NL_SET_ERR_MSG_ATTR(extack, a, "frequency is not supported by the device"); + NL_SET_ERR_MSG_ATTR(extack, a, + "frequency is not supported by the device"); return -EINVAL; } - xa_for_each(&pin->dpll_refs, i, ref) { - const struct dpll_pin_ops *ops = dpll_pin_ops(ref); - struct dpll_device *dpll = ref->dpll; - - if (!ops->frequency_set) + ops = dpll_pin_ops(ref); + if (!ops->frequency_set || !ops->frequency_get) return -EOPNOTSUPP; + } + ref = dpll_xa_ref_dpll_first(&pin->dpll_refs); + ops = dpll_pin_ops(ref); + dpll = ref->dpll; + ret = ops->frequency_get(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, + dpll_priv(dpll), &old_freq, extack); + if (ret) { + NL_SET_ERR_MSG(extack, "unable to get old frequency value"); + return ret; + } + if (freq == old_freq) + return 0; + + xa_for_each(&pin->dpll_refs, i, ref) { + ops = dpll_pin_ops(ref); + dpll = ref->dpll; ret = ops->frequency_set(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, dpll_priv(dpll), freq, extack); - if (ret) - return ret; + if (ret) { + failed = ref; + goto rollback; + } } __dpll_pin_change_ntf(pin); return 0; + +rollback: + xa_for_each(&pin->dpll_refs, i, ref) { + if (ref == failed) + break; + ops = dpll_pin_ops(ref); + dpll = ref->dpll; + if (ops->frequency_set(pin, dpll_pin_on_dpll_priv(dpll, pin), + dpll, dpll_priv(dpll), old_freq, extack)) + NL_SET_ERR_MSG(extack, "set frequency rollback failed"); + } + return ret; } static int -- 2.38.1 _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan