Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1427110pxb; Tue, 17 Aug 2021 11:22:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvQyi9k9jDUkNdruFubT12AdwSqes6cbvV0FCV9xdBdPFzWUqVV7G9bNaHrnUqUQJjH5AM X-Received: by 2002:a17:906:7d83:: with SMTP id v3mr5493396ejo.216.1629224568480; Tue, 17 Aug 2021 11:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629224568; cv=none; d=google.com; s=arc-20160816; b=deJSu70YBWhz6i/eQhd4MoQxAN5kAXoXnIpJ0zCi79+EXUkNNRVf66qu/Fdlm0x0GN Q9Zzp7YiLaUlxd1F+6V+F7stm9zc3KOkUuYhtDXvX2KNXrHHJeLi2f5pc7F0Thi6qMsd 0jHceTpEOaKngvXFx9bJbvR0aITawfRPbYBgc1mcnvV0wt9Jr5ETGuiWgM81iVZDmBFZ g9j14WrxhDdfIfknOXbmnT+FdMLuYKERuWCJK77+CYCpvPZO7NpeaomNEFGTaSeEAtQi LhN6QkV9XmafPgm7euLXr7jOx1nPJhO29Ql/GlrMyskp3+zR6c8qV8sP72BcNCeS63it Ns/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JxMZknPb38LEML/Zrl22ADbZSOPinCE/VRi5nWGWDAk=; b=00P+mJEFTw9Gi10wypZvfhFis8TFCo30LPsGsXTtLYuJ9QiurrsdPSIcDHG9uLyiCv LUUrlmTWQtno4oILXN0kCP7+nJVOfaJnP3J72Wy1VeK9pLF6JMB3ytrYcjcLr0nVZyxR IXT5YsIBMKZeSCBe/lx0BtIDJzQq/zBkGTyW/+b1PYl9pQVPD3xiEhE1VK/Y7NBO4jUN xvaNRuQ1Ao3ANlwC+RW33ob8iM/eMsvMSR/PKY1b/954ZoUQg53djCoG8121pUm2HgUp 642VaOTkjtshXBypsbEoBc+9EIKhsIyYK3T1pCbsWTJ9pXcnyRajyceHOKcoF/GzKeHp /1OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@essensium.com header.s=google header.b=PA0YPSPT; 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=essensium.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si3302961eds.480.2021.08.17.11.22.24; Tue, 17 Aug 2021 11:22:48 -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=@essensium.com header.s=google header.b=PA0YPSPT; 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=essensium.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232605AbhHQSVT (ORCPT + 99 others); Tue, 17 Aug 2021 14:21:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbhHQSVS (ORCPT ); Tue, 17 Aug 2021 14:21:18 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67A25C061764 for ; Tue, 17 Aug 2021 11:20:44 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id q3so28682989edt.5 for ; Tue, 17 Aug 2021 11:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=JxMZknPb38LEML/Zrl22ADbZSOPinCE/VRi5nWGWDAk=; b=PA0YPSPT/zjM5bEyc//9e/LK7/9ORKt+R0DfSzP2LM1QT9rCEMTMm/8yggAlOSiQNe P6Vb2m2vXpSGRgiIFaX4UtvsfmAstlOMNQkMhSX9UKoTc7AwLb2KlwWPw6WKu/5jYrv/ KiPtkO53kzroV+bjaJi7FCDY/pWOKVkqi7od/aLINjO/5Cy02Jq5X1qabP4g178wjYd8 OEz5+k2yYdKilKtoU7l0dNdbo2VY5rR9aNtkrlqIq1k1NLVctLaI1e1jLJkSfdYuGZDW ddrU9e5EvQQLLwMLEBs84gvbaAnrglNoGz2Dh7Wx3L/2Jazh3h59wXKY2ob6YTN6dPB+ 7VNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=JxMZknPb38LEML/Zrl22ADbZSOPinCE/VRi5nWGWDAk=; b=bnzpIvabFiIaQLDuQTHCl3IrnxbgsIgyGa1ntrRv8/Vb9xJBEyYA12DY+1S11AIzJB FjiHV9k05PjOhAYv+7fIWqmdFmFIsBNTrToMiS/qIpA+s6s/KM8laBGawqUoZLzJCGUh D6brQ9nhtT1GAxubA0WX2bvV41mIZArjepqO5USYd+/5O3s2VEMaIPtJ10dPtPfvFye+ 9F2M4/VeCZnZlVqhEngUa9raUbuSyWucoUwZBjFgVzrTyzruDMupvnnj0SwJPYCh4kTx AJvGaf+CxYvN+9erXdNRxzu3TvFXNAUHbjBOWiYPZ5k7igkDA7++zSrxF1FrlXhrL8P5 NE9g== X-Gm-Message-State: AOAM531+YQbFY9geF9DD4/mi4IZcdGpLr0g9McY24eEOdST2iaiyS1gf /YY77jE/sWILdTOedxUKSPX4lQ== X-Received: by 2002:a05:6402:8da:: with SMTP id d26mr5460218edz.109.1629224442987; Tue, 17 Aug 2021 11:20:42 -0700 (PDT) Received: from cephalopod (168.7-181-91.adsl-dyn.isp.belgacom.be. [91.181.7.168]) by smtp.gmail.com with ESMTPSA id cr9sm1409545edb.17.2021.08.17.11.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 11:20:42 -0700 (PDT) Date: Tue, 17 Aug 2021 20:20:40 +0200 From: Ben Hutchings To: Pavel Machek Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, "David S. Miller" , Sasha Levin Subject: Re: [PATCH 5.10 51/96] net: dsa: microchip: Fix ksz_read64() Message-ID: <20210817182040.GA12678@cephalopod> References: <20210816125434.948010115@linuxfoundation.org> <20210816125436.659359567@linuxfoundation.org> <20210817175630.GB30136@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210817175630.GB30136@amd> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 17, 2021 at 07:56:30PM +0200, Pavel Machek wrote: > Hi! > > > [ Upstream commit c34f674c8875235725c3ef86147a627f165d23b4 ] > > > > ksz_read64() currently does some dubious byte-swapping on the two > > halves of a 64-bit register, and then only returns the high bits. > > Replace this with a straightforward expression. > > The code indeed is very strange, but there are just 2 users, and they > will now receive byteswapped values, right? If it worked before, it > will be broken. The old code swaps the bytes within each 32-bit word, attempts to concatenate them into a 64-bit word, then swaps the bytes within the 64-bit word. There is no need for byte-swapping, only (on little- endian platforms) a word-swap, which is what the new code does. > Did this get enough testing for -stable? Yes, I actually developed and tested all the ksz8795 changes in 5.10 before forward-porting to mainline. > Is hw little endian or high endian or...? The hardware is big-endian and regmap handles any necessary byte-swapping for values up to 32 bits. > Note that ksz_write64() still contains the strange code, at least in > 5.10. It's unnecessarily complex, but it does work. Ben. > > Best regards, > Pavel > > > +++ b/drivers/net/dsa/microchip/ksz_common.h > > @@ -210,12 +210,8 @@ static inline int ksz_read64(struct ksz_device *dev, u32 reg, u64 *val) > > int ret; > > > > ret = regmap_bulk_read(dev->regmap[2], reg, value, 2); > > - if (!ret) { > > - /* Ick! ToDo: Add 64bit R/W to regmap on 32bit systems */ > > - value[0] = swab32(value[0]); > > - value[1] = swab32(value[1]); > > - *val = swab64((u64)*value); > > - } > > + if (!ret) > > + *val = (u64)value[0] << 32 | value[1]; > > > > return ret; > > } > > -- > DENX Software Engineering GmbH, Managing Director: Wolfgang Denk > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany -- Ben Hutchings ? Senior Embedded Software Engineer, Essensium-Mind ? mind.be