Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4450810imw; Tue, 19 Jul 2022 06:54:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uYyTRvo9RVMKC92CUoeuqCWdKt7+cI9UR0qzGcqtRrTbdI95SqmUVULZBdVrphGZ3Uuhkr X-Received: by 2002:a05:6402:430f:b0:43a:d521:bda with SMTP id m15-20020a056402430f00b0043ad5210bdamr45044046edc.69.1658238861096; Tue, 19 Jul 2022 06:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238861; cv=none; d=google.com; s=arc-20160816; b=NzHrGNkm2BC3ZaLRkkgTTjb7lfmQZl3X2WhQ49ICzEsF9leJIVSBKg5+rKpTRk8dVa do3Qy4EFn2+rwYhADAdmBRsWU3RozEVjz49O5MXjPd7Yns2kQy9jurrF6gNs2uxwELR2 ogq5+99p04T9d7RZZ5oeNhZUoZmvr9ylsu2yBgFWtB8fO3odwkiqdWV9G/+NwAsdVtZd MeHqoEKv2v0EMhFLbnNw2vElBuqyrctQYaXt8785AjLxypFYvcozK9sk7XkHVLc8toFa fvZ16xQKWV8Ml78kDwBHNuWljKvya0LzAG9WX7j9vnbXgI9fbwuUStVC5JyYUf3wrtnJ PXTA== 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=AjOghYfiFGttkBV9zXTy9V0BLrHJ9AkwAFopITJkoPw=; b=wdqtgrkzOcxFBGYw69AAQFhJKF4degnOTAbByLxSzE2LGeSoQKF8xV/FQjFvVRBxDY zuAWmasv98ikSdmjOu4iYp0IIMqRDDcpXCCNiLIDvKKElPXVpH2wwM9yI1YF63lrR/9E D9NNCcmGCMcLYShetfBXOJIgcoMgttitQKRoXpk71gv3QetMUY/9GlqAkQH53S3UBH+y vSZfmpFuP1EKUgPZEp4S8A19JrVObxehBOq3yvIt218U9IFfjKdZUIAac22GvmLPVcMI dH/cSNr+cM+EjZ0Q+EY8VqVCZdh2hVB6of5VrRHT/bQqpwJnJ2flQdsCxsTrAnNYuSlA k9gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fCQ5TWP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fj12-20020a1709069c8c00b0072b91f3d51dsi15129669ejc.290.2022.07.19.06.53.56; Tue, 19 Jul 2022 06:54:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fCQ5TWP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S240838AbiGSMha (ORCPT + 99 others); Tue, 19 Jul 2022 08:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240682AbiGSMgs (ORCPT ); Tue, 19 Jul 2022 08:36:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 160B86464; Tue, 19 Jul 2022 05:14:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1507861746; Tue, 19 Jul 2022 12:13:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBB04C341C6; Tue, 19 Jul 2022 12:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232831; bh=USoxJJmNigTeOjCpA6MsQrQcsLyDaGVfZyfTu4lJXjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fCQ5TWP8OSY0HL8Y6eY2opfFQ2VkoG8w9ICHRuvpztYdBlGXT0sjdqycYNSUqPOtj AQoGWia25V/BJMzJ/RequBmy1Do4JSOnHmXHD1ZgA8pwjlaydf6RHnSaNVkdICjSo1 QSU6qWC7B1WZystVnfBOpp0KtihwJ4d6RMKwl9+A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Cochran , Pavan Chebbi , Michael Chan , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 081/167] bnxt_en: Fix bnxt_refclk_read() Date: Tue, 19 Jul 2022 13:53:33 +0200 Message-Id: <20220719114704.408719777@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavan Chebbi [ Upstream commit ddde5412fdaa5048bbca31529d46cb8da882870c ] The upper 32-bit PHC register is not latched when reading the lower 32-bit PHC register. Current code leaves a small window where we may not read correct higher order bits if the lower order bits are just about to wrap around. This patch fixes this by reading higher order bits twice and makes sure that final value is correctly paired with its lower 32 bits. Fixes: 30e96f487f64 ("bnxt_en: Do not read the PTP PHC during chip reset") Cc: Richard Cochran Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index 62a931de5b1a..a78cc65a38f2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -61,14 +61,23 @@ static int bnxt_refclk_read(struct bnxt *bp, struct ptp_system_timestamp *sts, u64 *ns) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; + u32 high_before, high_now, low; if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) return -EIO; + high_before = readl(bp->bar0 + ptp->refclk_mapped_regs[1]); ptp_read_system_prets(sts); - *ns = readl(bp->bar0 + ptp->refclk_mapped_regs[0]); + low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]); ptp_read_system_postts(sts); - *ns |= (u64)readl(bp->bar0 + ptp->refclk_mapped_regs[1]) << 32; + high_now = readl(bp->bar0 + ptp->refclk_mapped_regs[1]); + if (high_now != high_before) { + ptp_read_system_prets(sts); + low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]); + ptp_read_system_postts(sts); + } + *ns = ((u64)high_now << 32) | low; + return 0; } -- 2.35.1