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 smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 1CBABE8FDDD for ; Wed, 4 Oct 2023 09:09:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CCCEB40134; Wed, 4 Oct 2023 09:09:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org CCCEB40134 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1696410541; 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=PiyScX4qFcLgUldtinKuL2p7uW7LRLaWJsK4UAcpNoCShZHd/wCmISrihoiU5Gcqp aWP4fOjG9EmHh+/vPb6VRefwWxSAQUnztqGGdYCU0jF2vjgXC9ajDIEQXc4/lRR6Jv 5pU/kJ5hBAMJsvUZZO8glSZhS91vY1Bt2hcn3mtXgLDW+EXMq4qpU5wGtdb2ZN9MFW KcQbi6Hrj8za77ou3tzvPBK7d/tJnnPu2DqRc7igT7VeKQ31EbIxjxA+XC0b/D50/6 Y2WROqJJmw/Bx1Ol4sXWYh6AsIHBmgQhn+khIdfmQTExGciH3ZawnI6zhINn0S+jzz FgtBC11PMZLzQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VI6DPw2L2iYL; Wed, 4 Oct 2023 09:09:01 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id BC68041919; Wed, 4 Oct 2023 09:09:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org BC68041919 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 9C8CC1BF41C for ; Wed, 4 Oct 2023 09:08:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 803F54206B for ; Wed, 4 Oct 2023 09:08:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 803F54206B X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I29eEDdvR-at for ; Wed, 4 Oct 2023 09:08:47 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by smtp4.osuosl.org (Postfix) with ESMTPS id 425034206A for ; Wed, 4 Oct 2023 09:08:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 425034206A X-IronPort-AV: E=McAfee;i="6600,9927,10852"; a="373448549" X-IronPort-AV: E=Sophos;i="6.03,199,1694761200"; d="scan'208";a="373448549" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2023 02:08:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10852"; a="780668482" X-IronPort-AV: E=Sophos;i="6.03,199,1694761200"; d="scan'208";a="780668482" Received: from amlin-018-114.igk.intel.com ([10.102.18.114]) by orsmga008.jf.intel.com with ESMTP; 04 Oct 2023 02:08:44 -0700 From: Arkadiusz Kubalewski To: netdev@vger.kernel.org Date: Wed, 4 Oct 2023 11:05:47 +0200 Message-Id: <20231004090547.1597844-6-arkadiusz.kubalewski@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20231004090547.1597844-1-arkadiusz.kubalewski@intel.com> References: <20231004090547.1597844-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=1696410527; x=1727946527; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T7B4f7810U0FdBKSEAXDN5xAeXxcWlTekOw+2N8jEHU=; b=knu1Gli8qjvqpdiojM9/ON6loiEt4cLxZJz709nSEPc4C9pE9XIZ+pD/ wd/VRIS+MqkHaS3q55gmhtBRtCrAYm5qg4+WKEQuPQJ+JpLVYmAjVqXk+ syZ4/lcRoaHW89imW7UbZpg9T2/1FxG7PSJrFGj40ESk42Bq//VGFviSx uo69gUl4Txq7+vEAOYIWZnLz5VC3CWl91jrx7vb3fCphXjZfLaGlLV1Or zhqXaUoaCECS5lqh59axL/s6dE9Km26BFnvGOpG7WPagFcqDa5vQxklNu 2wCymzPUIHFUTlG+evrC0H5iXCkTQ1hLcguN+qMNcSrCqdx2nlsEfbEMo A==; X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=knu1Gli8 Subject: [Intel-wired-lan] [PATCH net-next v2 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