From patchwork Fri Jul 23 21:53:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 485581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, MIME_NO_TEXT, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12258C432BE for ; Fri, 23 Jul 2021 21:54:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEA0D60E95 for ; Fri, 23 Jul 2021 21:54:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232296AbhGWVN2 (ORCPT ); Fri, 23 Jul 2021 17:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231839AbhGWVN1 (ORCPT ); Fri, 23 Jul 2021 17:13:27 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD60CC061575 for ; Fri, 23 Jul 2021 14:54:00 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id hg12-20020a17090b300cb02901736d9d2218so5581367pjb.1 for ; Fri, 23 Jul 2021 14:54:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=IGcnbuVmFPR0pMbqwK5iKbG88dGeNRny+rAro+URQg8=; b=KD/j3w5zbv9s8aaNKHPqQp3hfeddbRtN2zgZrzaaL0OT6Fxm+7JFCEnJh6dKSoiUUM TMpRFGvbHFAbDa60z03Efbzx5JbOxSGD/D2tlKUFuv/lKbw0e/lVmfz232Mq7Fgv3Ydk C0+ZaO9UVNdZ4em/4v1T1u793xbfy5DCKi2VY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IGcnbuVmFPR0pMbqwK5iKbG88dGeNRny+rAro+URQg8=; b=IDXT4HM7wT95XqVVeEHnqkhxlvs9oQsTYPf4mxzBtj6bf7Lw5Bw7fKqMI9YbkhdFul CkROjRlOJPcKbSdjBxAYOZNtbOnmgqJZxZ4TwoMq040oi0Xo5pIcSSeJVZbsxYeZu3n8 nWUz5Uy6k8sKWFtcdPkbeuROhe1wQ/JF6e5Sk017R46hNQ1Ye5yFbTP0jz6bNG6UHhKi 8IHq/+TQyjYRPTMh4jsJlsataaf/buV/ttqDLmNJoWKVpjMYgaAjVtY3wUvbY9IBQgWU UKTgUDkf/cDVMoHYpEVVHasYloJi3tg+6HW5JLayVxrWGnRx+mOUOvoaBeNfUhRnxPxX n1Iw== X-Gm-Message-State: AOAM530qiZdSqlMGW2az9YiNqi/mdb5VmwHXegqOGEcRUyjAwlI5l5fN si5Aye4Dv8tZUv6YM+DdfZL7gH8olDQTGA== X-Google-Smtp-Source: ABdhPJyMDjMLgHAJXIq59NUyqjG/cVKxEbZw/BHJ2gk4RxpQS6WkRoDHpcrrQzZAIJhw1aX9g7R/jQ== X-Received: by 2002:a63:34a:: with SMTP id 71mr6703558pgd.289.1627077239645; Fri, 23 Jul 2021 14:53:59 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id w3sm6963591pjq.12.2021.07.23.14.53.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jul 2021 14:53:59 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com, richardcochran@gmail.com, pavan.chebbi@broadcom.com Subject: [PATCH net] bnxt_en: Add missing periodic PHC overflow check Date: Fri, 23 Jul 2021 17:53:48 -0400 Message-Id: <1627077228-887-1-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We use the timecounter APIs for the 48-bit PHC and packet timestamps. We must periodically update the timecounter at roughly half the overflow interval. The overflow interval is about 78 hours, so update it every 19 hours (1/4 interval) for some extra margins. Fixes: 390862f45c85 ("bnxt_en: Get the full 48-bit hardware timestamp periodically") Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 7 +++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index 9089e7f3fbd4..ec381c2423b8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -353,6 +353,12 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) bnxt_ptp_get_current_time(bp); ptp->next_period = now + HZ; + if (time_after_eq(now, ptp->next_overflow_check)) { + spin_lock_bh(&ptp->ptp_lock); + timecounter_read(&ptp->tc); + spin_unlock_bh(&ptp->ptp_lock); + ptp->next_overflow_check = now + BNXT_PHC_OVERFLOW_PERIOD; + } return HZ; } @@ -423,6 +429,7 @@ int bnxt_ptp_init(struct bnxt *bp) ptp->cc.shift = 0; ptp->cc.mult = 1; + ptp->next_overflow_check = jiffies + BNXT_PHC_OVERFLOW_PERIOD; timecounter_init(&ptp->tc, &ptp->cc, ktime_to_ns(ktime_get_real())); ptp->ptp_info = bnxt_ptp_caps; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h index 4135ea3ec788..254ba7bc0f99 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h @@ -32,6 +32,10 @@ struct bnxt_ptp_cfg { u64 current_time; u64 old_time; unsigned long next_period; + unsigned long next_overflow_check; + /* 48-bit PHC overflows in 78 hours. Check overflow every 19 hours. */ + #define BNXT_PHC_OVERFLOW_PERIOD (19 * 3600 * HZ) + u16 tx_seqid; struct bnxt *bp; atomic_t tx_avail;