Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp214163rwe; Fri, 14 Apr 2023 01:21:39 -0700 (PDT) X-Google-Smtp-Source: AKy350ZmqSwGOUwXPEo2DnKESfyjYI6bS/oEBDBS6lwDoiTXt1y619UyBXVmIXmKpqGjknCcAuHM X-Received: by 2002:a05:6a00:2191:b0:63b:599b:a2da with SMTP id h17-20020a056a00219100b0063b599ba2damr4758420pfi.27.1681460499682; Fri, 14 Apr 2023 01:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681460499; cv=none; d=google.com; s=arc-20160816; b=XS9lnU4OA5iih4WDD8LvGat6gWC0S/BYKQx+Sjx0anv7Me3Jt7Oh7f/MYm/wIpPLH2 kZil0Up+PcJCQxv1US+q3arauJaO2vKaB0KIgts4DUMA1xeDacmOUxuPYImJQ4WiglJV VUCbuuKE8+Yd7ISDBd/8OcaQB9PWlAD0Y0A+QXqaFdQ2+2PvXGSrEvtjTA22VpaQb+59 QqfLYLOEV5xv2r1UQYwpODBeAVLd5bk1d0fDbsIW/R5zUkVMgr27ZgUoWb8j+aqb6wTm Pp+L4vIjlVsv/dfn3UbLSI/DSqNSTP3OIhU5ypse8GtokgRFHIla8CVtjuquSmS5Fe5z eM1A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=8MJwVVvwYCR27e9eNHpHI4xE2ysR73I/Gr/3qYH/+RI=; b=oPR1raW1oS3tSOsNrfddZlQzFP/sQ5BFzKIQ5fLNTZ4sfGW4kteU+xy+XymqLMszJ2 Qx42bu9GcS2FvHyP6IYj5eoP+Injxsr/olJ/BBoUoy4QxzsoJ90oLRbBbyBaoI5pMOqZ h9IqhuPTGNAFdq1S1YjtkoffnwtTNFHMsLCcCIFjB44ANb27UC9H+Q+8amVK2027niYO HGu/VE4axLdTE9KtQdQzKT8FkSF2Yfr40SGYCjO3U0ts9IkAj3ktTbcYEhoox7Qwykj2 KaxKJNfc72ZpgeY515FdkEr3aeLF/JGGpax8I0a3AbgaW47NhbTUA8gxvZHejn98afIm VAcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=vZxv27T7; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w23-20020aa79557000000b0062af960641dsi3868940pfq.255.2023.04.14.01.21.26; Fri, 14 Apr 2023 01:21:39 -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=@microchip.com header.s=mchp header.b=vZxv27T7; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbjDNIVD (ORCPT + 99 others); Fri, 14 Apr 2023 04:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230096AbjDNIVB (ORCPT ); Fri, 14 Apr 2023 04:21:01 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84F3830C4; Fri, 14 Apr 2023 01:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1681460457; x=1712996457; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rtLuS5HdkkGf6K1pvoN/8HXKoYmlRrjzY3AWTl9DpU8=; b=vZxv27T7W4bK5nlitQzwDF5X6zK27TwiWKgxlWMNOLsG/qLXZTwxnEWl wXJI79CKFFCRfHTyYxqvwVMoOGMwnyhoGoXYdJPLu5fEG+cKW3k+6z1t9 RVx2ao1QDSOimY105W7iYKPhSsTCu1FIq5Rg686/KPMPVPh3fseJzPrHB Ey2nkShEbben+2y0tRDqBVFboH+AgEcz0MaUBrIjrvHkXMWRQ3rBvh4Nl wC/sI14BnJ4ILhPLRQN6RKSNofGhq9Fnvfl66HApgmByfkDGwRN0ugELD rrm06xzF65n0MUgsSQGGJXTniw3eBbqKa2V2pMYdsPxnEklz22He6YT9D w==; X-IronPort-AV: E=Sophos;i="5.99,195,1677567600"; d="scan'208,223";a="210429983" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Apr 2023 01:20:55 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Fri, 14 Apr 2023 01:20:52 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Fri, 14 Apr 2023 01:20:51 -0700 From: Horatiu Vultur To: , CC: , , , , , Horatiu Vultur Subject: [PATCH net-next] net: lan966x: Fix lan966x_ifh_get Date: Fri, 14 Apr 2023 10:20:47 +0200 Message-ID: <20230414082047.1320947-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 time to time, it was observed that the nanosecond part of the received timestamp, which is extracted from the IFH, it was actually bigger than 1 second. So then when actually calculating the full received timestamp, based on the nanosecond part from IFH and the second part which is read from HW, it was actually wrong. The issue seems to be inside the function lan966x_ifh_get, which extracts information from an IFH(which is an byte array) and returns the value in a u64. When extracting the timestamp value from the IFH, which starts at bit 192 and have the size of 32 bits, then if the most significant bit was set in the timestamp, then this bit was extended then the return value became 0xffffffff... . To fix this, make sure to clear all the other bits before returning the value. Fixes: fd7627833ddf ("net: lan966x: Stop using packing library") Signed-off-by: Horatiu Vultur --- drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 80e2ea7e6ce8a..508e494dcc342 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -608,6 +608,7 @@ static u64 lan966x_ifh_get(u8 *ifh, size_t pos, size_t length) val |= (1 << i); } + val &= GENMASK(length, 0); return val; } -- 2.38.0