Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3014263ybi; Fri, 5 Jul 2019 00:14:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/8KXHbYKnjFn6NTLr7DzI7OWcjEQaYHQ2CTiB/sxHF70r8fG6SRc1xGW7A92I0hYNcfHK X-Received: by 2002:a17:90a:ca0f:: with SMTP id x15mr3117861pjt.82.1562310868686; Fri, 05 Jul 2019 00:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562310868; cv=none; d=google.com; s=arc-20160816; b=oanOAJo+E+Ro6B0qiKANqHJQvtsrlX1zqAsCN5Gx4CcXm+UYOxyPX6W5nQUrwyuPyF ydTLj1rJKsASH6KqaiEZM/rghEFDmGHJfXxRvqlzvqks5o/RLupq+Yi+XrJpJq7DJf3X mSaTlghn2byA2PbMwjVTSWOJsceEEOwjbrM/x47w626CeUClVw8d8dphT9Ndl4kb3PHK U329NrwcyyHBQ2bPOO/s53q0EU2K4TrekNy5lr2b8LhmJhdGjrjmAPA+VdRbRJQJpdQ0 zE9sQMYqeV14TmcIqXnE57iUo6zFJwel3Ve/gPXzh7o5jYldJicI0Fh6Ov1zqpm6hb2B 5A6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=YtAfMv3b0EzxZEwmiODN0NZYCjvs3z8tavD+PRQ2Htw=; b=jdZFAdBGLoAvyIl87JPXOdnUAGWz5JJvZM8yfIQzPxpTF22d4r6R+OICeTz1GbCjMu uagsSo7+spmxe4UOUMDHnOgGS1F8ygH46chsvkMJbNBk2xvx98hwqpQArlhIqsLysFAt Ih7ZDQZ3ysNHg105Wt/kn0Z+XUlOA6nj8ryhxZnpcKMeC4cjlMk73xgaTEB89rLUCiQV ETf/MO0WVAOWhAWUwAO8OSHVYy54uKCD2/pnBvo8AyioAPLMs0aCQtgXH/hgJxe6N8/j dr39Hg27NaWaccOyN4Olc+10seel7WxSNgXfClNzXc4qyspnVrBJ6nGIgA8rDcqAWe5K F0dA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1si1101096pgv.58.2019.07.05.00.14.13; Fri, 05 Jul 2019 00:14:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727865AbfGEHMr convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 Jul 2019 03:12:47 -0400 Received: from mailout01.agenturserver.de ([185.15.192.32]:49125 "EHLO mailout01.agenturserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbfGEHMq (ORCPT ); Fri, 5 Jul 2019 03:12:46 -0400 Received: from mail02.agenturserver.de (mail02.internal [172.16.51.35]) by mailout01.agenturserver.de (Postfix) with ESMTP id 2BC0166DE1; Fri, 5 Jul 2019 09:12:42 +0200 (CEST) Received: from localhost (ac02.internal [172.16.51.82]) by mail02.agenturserver.de (Postfix) with ESMTP id 1B8DB807EC; Fri, 5 Jul 2019 09:12:42 +0200 (CEST) X-Spam-Level: Received: from mail.agenturserver.de ([172.16.51.35]) by localhost (ac02.mittwald.de [172.16.51.82]) (amavisd-new, port 10026) with ESMTP id caKduJbWk4PB; Fri, 5 Jul 2019 09:12:41 +0200 (CEST) Received: from karo-electronics.de (unknown [89.1.81.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lw@karo-electronics.de) by mail.agenturserver.de (Postfix) with ESMTPSA; Fri, 5 Jul 2019 09:12:36 +0200 (CEST) Date: Fri, 5 Jul 2019 09:12:35 +0200 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= To: Andy Duan Cc: "srinivas.kandagatla@linaro.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "kernel@pengutronix.de" , "festevam@gmail.com" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [EXT] Re: [PATCH nvmem 1/1] nvmem: imx: correct the fuse word index Message-ID: <20190705091235.365b93cb@karo-electronics.de> In-Reply-To: References: <20190704142015.10701-1-fugang.duan@nxp.com> <20190704174543.194a0158@karo-electronics.de> Organization: Ka-Ro electronics GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, 5 Jul 2019 02:46:32 +0000 Andy Duan wrote: > From: Andy Duan Sent: Friday, July 5, 2019 12:08 AM > > From: Lothar Waßmann Sent: Thursday, July 4, > > 2019 11:46 PM > > > Hi, > > > > > > On Thu, 4 Jul 2019 22:20:15 +0800 fugang.duan@nxp.com wrote: > > > > From: Fugang Duan > > > > > > > > iMX8 fuse word index represent as one 4-bytes word, it should not be > > > > divided by 4. > > > > > > > > Exp: > > > > - MAC0 address layout in fuse: > > > > offset 708: MAC[3] MAC[2] MAC[1] MAC[0] > > > > offset 709: XX xx MAC[5] MAC[4] > > > > > > > > Signed-off-by: Fugang Duan > > > > --- > > > > drivers/nvmem/imx-ocotp-scu.c | 6 +++--- > > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/drivers/nvmem/imx-ocotp-scu.c > > > > b/drivers/nvmem/imx-ocotp-scu.c index d9dc482..be2f5f0 100644 > > > > --- a/drivers/nvmem/imx-ocotp-scu.c > > > > +++ b/drivers/nvmem/imx-ocotp-scu.c > > > > @@ -71,8 +71,8 @@ static int imx_scu_ocotp_read(void *context, > > > > unsigned > > > int offset, > > > > void *p; > > > > int i, ret; > > > > > > > > - index = offset >> 2; > > > > - num_bytes = round_up((offset % 4) + bytes, 4); > > > > + index = offset; > > > > + num_bytes = round_up(bytes, 4); > > > > count = num_bytes >> 2; > > > > > > > > if (count > (priv->data->nregs - index)) @@ -100,7 +100,7 @@ > > > > static int imx_scu_ocotp_read(void *context, unsigned int offset, > > > > buf++; > > > > } > > > > > > > > - memcpy(val, (u8 *)p + offset % 4, bytes); > > > > + memcpy(val, (u8 *)p, bytes); > > > > > > > > kfree(p); > > > > > > > With these changes you could use the 'val' pointer directly as the > > > destination for ocotp_read() without need for an intermediate buffer. > > > > > > > > > Lothar Waßmann > > > > You are right, in fact, we can remove "p" and "buf" pointer. > > Thanks for your review, I will send out the V2. > > Hi Lothar, > > It still need intermediate buffer to read out n words (n * 4 bytes) from eFuse. > Because 'val' buffer size is real count parsed from DT, which is not an integer multiple of 4. > > For example, cell->bytes is parsed from "reg" property and it is real count like 6. > fec_mac0: mac@2c4 { > reg = <0x2c4 6>; > }; > > So we have to use intermediate buffer here. > val is a u32 pointer, so legally it cannot point to any buffer whose size is not divisible by four! Lothar Waßmann