All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Keeping <john@metanate.com>
To: Jonas Karlman <jonas@kwiboo.se>
Cc: Simon Glass <sjg@chromium.org>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Kever Yang <kever.yang@rock-chips.com>,
	u-boot@lists.denx.de
Subject: Re: [PATCH] rockchip: efuse: fix rk3399 reading multiple values
Date: Thu, 20 Apr 2023 12:16:48 +0100	[thread overview]
Message-ID: <ZEEfIEWgjDxCNToh@donbot> (raw)
In-Reply-To: <ZD2IwKnrFfKT3vQQ@donbot>

On Mon, Apr 17, 2023 at 06:58:30PM +0100, John Keeping wrote:
> On Mon, Apr 17, 2023 at 05:39:24PM +0000, Jonas Karlman wrote:
> > On 2023-04-17 18:09, John Keeping wrote:
> > > Update rk3399 to match the pattern in the other device-specific
> > > implementations to ensure the previous address is cleared when reading
> > > multiple blocks.
> > 
> > Does this fix a real issue for you?
> > 
> > Compared to the other device-specific implementations this reg behaves
> > differently on RK3399. The addr field is not read back, or it gets
> > auto-cleared when EFUSE_STROBE is cleared, the use of clrsetbits_le32
> > may mislead that this reg holds the addr value from prior iteration.
> 
> I don't have an RK3399 to test with, but I spotted this when
> experimenting with RK3288's secure efuse which has a similar layout to
> the RK3399 efuses.
> 
> Having looked through the RK3399 TRM, I can't see anything about the
> address auto-clearing and the documentation for redundancy read mode
> requiring two strobe cycles suggests that the address is preserved.
> 
> Howe are you testing reads?  dump_efuse only reads one block at a time
> so it isn't sufficient to trigger an issue here as there is an
> unconditional write to EFUSE_CTRL before this loop.

I found an RK3399 which I had for a previous project and have now tested
this - I can't see any evidence of the address auto-clearing so it looks
to me like this patch fixes a real issue.

> > > 
> > > Signed-off-by: John Keeping <john@metanate.com>
> > > ---
> > >  drivers/misc/rockchip-efuse.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
> > > index 2f96b79ea4..d302271239 100644
> > > --- a/drivers/misc/rockchip-efuse.c
> > > +++ b/drivers/misc/rockchip-efuse.c
> > > @@ -207,8 +207,8 @@ static int rockchip_rk3399_efuse_read(struct udevice *dev, int offset,
> > >  	udelay(1);
> > >  
> > >  	while (size--) {
> > > -		setbits_le32(efuse->base + EFUSE_CTRL,
> > > -			     EFUSE_STROBE | RK3399_ADDR(offset++));
> > > +		clrsetbits_le32(efuse->base + EFUSE_CTRL, RK3399_A_MASK,
> > > +				EFUSE_STROBE | RK3399_ADDR(offset++));
> > >  		udelay(1);
> > >  		*buffer++ = readl(efuse->base + EFUSE_DOUT);
> > >  		clrbits_le32(efuse->base + EFUSE_CTRL, EFUSE_STROBE);
> > 

  parent reply	other threads:[~2023-04-20 11:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17 16:09 [PATCH] rockchip: efuse: fix rk3399 reading multiple values John Keeping
2023-04-17 17:39 ` Jonas Karlman
2023-04-17 17:58   ` John Keeping
2023-04-17 18:19     ` Jonas Karlman
2023-04-18 12:48       ` Jonas Karlman
2023-04-20 11:16     ` John Keeping [this message]
2023-04-20 11:30       ` Jonas Karlman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZEEfIEWgjDxCNToh@donbot \
    --to=john@metanate.com \
    --cc=jonas@kwiboo.se \
    --cc=kever.yang@rock-chips.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.