Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1902763pxb; Mon, 13 Sep 2021 07:51:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2sf5PEkdtjlS2xKs4LhDe9HyyNAbOGswq2FqnA3Pgs8aYAR7iL+zu6ZEhVnmb4/xXRo67 X-Received: by 2002:a17:906:bc97:: with SMTP id lv23mr12660350ejb.529.1631544684076; Mon, 13 Sep 2021 07:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631544684; cv=none; d=google.com; s=arc-20160816; b=ePRyhcZPEfOJzlXKHC/0LJEY8U2uDmkl3UA+PzjYDnIWp6ceL2DKUiQsOFFvQEsx5H 0QXuPUvFK57Jj883GnKxdP445e0mGf5EDRXKCa/4cd3AypTFmVEYXqIOw1bKquix10wv 7r1r11Qb6u8/E8g7EwUHL+wSdyW2Djp+ViP/dLeQtJbUGUA1752nCwI/jhPmIGIjrp9L WmZgOfbC+NDSkev70CcK4LR8L1G8Ax9q+T1X9ZI9EjyeBeLH9saFhRHIrIuNzbbmwejE bHsB3smeSuYKFTwWeX/yc79EaGe2ZEobvEsjn69GlXJ1FKP+hT17EQkzGNgpLa5FGKog N9ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nihTzLp7wt8innZ5llU2SUoZZ4hPoyOglT30yqe1v04=; b=0wBcSajtIW3dfwykMTmU6zZu2FtynI1zU1M95t1d/zHH2Q2fHPBGfqt1e7QHPaJxUt auvK5ptSe6DwZjYH4aYw9KPNaK1zLAUmsjTU4RdDpjmXHLAvrRRzou02oG/n1NclF9uf cE1rtBq7VjCQDM+ZWjMyKFO7CF1zMr6310pH0+74AmeCcy1/aV0IJi0///pn8PyK2zuE NhhmNL/MAh4O9kkuCfxUDnR7nC15zJl2OMWvYaffO719LVJ3X32MykftNF93EB0RVJJH sFdWF6Z2hDVLQgFdK+7ClrMrzG7TO6vnxBdBTGBnCv8D29thSrPvFC9D+1SBCX2c30Ni P8Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Rl2/hpge"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt9si7314074ejc.426.2021.09.13.07.50.57; Mon, 13 Sep 2021 07:51:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Rl2/hpge"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347457AbhIMOtX (ORCPT + 99 others); Mon, 13 Sep 2021 10:49:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:58832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347879AbhIMOo2 (ORCPT ); Mon, 13 Sep 2021 10:44:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 243CB619E5; Mon, 13 Sep 2021 13:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631541463; bh=pZCtz+VcQpMDqnOR2CpYb1dH7lWkFEP+jxz5KMy4HbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rl2/hpgellkZ0vwmifz3+lEnGGEhGaD0EZj9R+L1CPf5dbUJY64yIqbBtXVMZo1aJ bj9FTWSnxY2f1hfp7RL0ugrongxCX+qiFlZtQ1mBnFZNu8//W4qkui6hqvXWKTMqR7 XYBuSzYLiG5uVoezpBMAqtRS1BMq1+UYQXmogHbM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jacob Keller , Sunitha D Mekala , Tony Nguyen , Sasha Levin Subject: [PATCH 5.14 276/334] ice: restart periodic outputs around time changes Date: Mon, 13 Sep 2021 15:15:30 +0200 Message-Id: <20210913131122.756772719@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131113.390368911@linuxfoundation.org> References: <20210913131113.390368911@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jacob Keller [ Upstream commit 9ee313433c483e4a6ecd517c38c0f8aee1962c53 ] When we enabled auxiliary input/output support for the E810 device, we forgot to add logic to restart the output when we change time. This is important as the periodic output will be incorrect after a time change otherwise. This unfortunately includes the adjust time function, even though it uses an atomic hardware interface. The atomic adjustment can still cause the pin output to stall permanently, so we need to stop and restart it. Introduce wrapper functions to temporarily disable and then re-enable the clock outputs. Fixes: 172db5f91d5f ("ice: add support for auxiliary input/output pins") Signed-off-by: Jacob Keller Tested-by: Sunitha D Mekala Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_ptp.c | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 8970037177fe..234bc68e79f9 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -688,6 +688,41 @@ err: return -EFAULT; } +/** + * ice_ptp_disable_all_clkout - Disable all currently configured outputs + * @pf: pointer to the PF structure + * + * Disable all currently configured clock outputs. This is necessary before + * certain changes to the PTP hardware clock. Use ice_ptp_enable_all_clkout to + * re-enable the clocks again. + */ +static void ice_ptp_disable_all_clkout(struct ice_pf *pf) +{ + uint i; + + for (i = 0; i < pf->ptp.info.n_per_out; i++) + if (pf->ptp.perout_channels[i].ena) + ice_ptp_cfg_clkout(pf, i, NULL, false); +} + +/** + * ice_ptp_enable_all_clkout - Enable all configured periodic clock outputs + * @pf: pointer to the PF structure + * + * Enable all currently configured clock outputs. Use this after + * ice_ptp_disable_all_clkout to reconfigure the output signals according to + * their configuration. + */ +static void ice_ptp_enable_all_clkout(struct ice_pf *pf) +{ + uint i; + + for (i = 0; i < pf->ptp.info.n_per_out; i++) + if (pf->ptp.perout_channels[i].ena) + ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i], + false); +} + /** * ice_ptp_gpio_enable_e810 - Enable/disable ancillary features of PHC * @info: the driver's PTP info structure @@ -783,12 +818,17 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts) goto exit; } + /* Disable periodic outputs */ + ice_ptp_disable_all_clkout(pf); + err = ice_ptp_write_init(pf, &ts64); ice_ptp_unlock(hw); if (!err) ice_ptp_update_cached_phctime(pf); + /* Reenable periodic outputs */ + ice_ptp_enable_all_clkout(pf); exit: if (err) { dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); @@ -842,8 +882,14 @@ static int ice_ptp_adjtime(struct ptp_clock_info *info, s64 delta) return -EBUSY; } + /* Disable periodic outputs */ + ice_ptp_disable_all_clkout(pf); + err = ice_ptp_write_adj(pf, delta); + /* Reenable periodic outputs */ + ice_ptp_enable_all_clkout(pf); + ice_ptp_unlock(hw); if (err) { @@ -1554,6 +1600,9 @@ void ice_ptp_release(struct ice_pf *pf) if (!pf->ptp.clock) return; + /* Disable periodic outputs */ + ice_ptp_disable_all_clkout(pf); + ice_clear_ptp_clock_index(pf); ptp_clock_unregister(pf->ptp.clock); pf->ptp.clock = NULL; -- 2.30.2