netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joakim Zhang <qiangqing.zhang@nxp.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>,
	"linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Cc: dl-linux-imx <linux-imx@nxp.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [PATCH linux-can-next/flexcan 1/4] can: flexcan: initialize all flexcan memory for ECC function
Date: Sun, 27 Sep 2020 08:01:16 +0000	[thread overview]
Message-ID: <DB8PR04MB6795C88B839FE5083283E157E6340@DB8PR04MB6795.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <f98dcb18-19f9-9721-a191-481983158daa@pengutronix.de>


Hi Marc,

> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: 2020年9月25日 15:29
> To: Joakim Zhang <qiangqing.zhang@nxp.com>; linux-can@vger.kernel.org
> Cc: dl-linux-imx <linux-imx@nxp.com>; netdev@vger.kernel.org
> Subject: Re: [PATCH linux-can-next/flexcan 1/4] can: flexcan: initialize all flexcan
> memory for ECC function
> 
> On 9/25/20 5:10 PM, Joakim Zhang wrote:
> > There is a NOTE at the section "Detection and correction of memory errors":
> 
> Can you add a reference to one datasheet including name, revision and
> section?
> 
> > All FlexCAN memory must be initialized before starting its operation
> > in order to have the parity bits in memory properly updated.
> > CTRL2[WRMFRZ] grants write access to all memory positions that require
> > initialization, ranging from 0x080 to 0xADF and from 0xF28 to 0xFFF
> > when the CAN FD feature is enabled. The RXMGMASK, RX14MASK,
> RX15MASK,
> > and RXFGMASK registers need to be initialized as well. MCR[RFEN] must not
> be set during memory initialization.
> >
> > Memory range from 0x080 to 0xADF, there are reserved memory
> > (unimplemented by hardware), these memory can be initialized or not.
> >
> > Initialize all FlexCAN memory before accessing them, otherwise, memory
> > errors may be detected. The internal region cannot be initialized when
> > the hardware does not support ECC.
> >
> > Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> > +	reg_ctrl2 = priv->read(&regs->ctrl2);
> > +	reg_ctrl2 |= FLEXCAN_CTRL2_WRMFRZ;
> > +	priv->write(reg_ctrl2, &regs->ctrl2);
> > +
> > +	/* initialize MBs RAM */
> > +	size = sizeof(regs->mb) / sizeof(u32);
> > +	for (i = 0; i < size; i++)
> > +		priv->write(0, &regs->mb[0][0] + sizeof(u32) * i);
> 

[...]
> Can you create a "static const struct" holding the reg (or offset) + len and loop
> over it. Something linke this?
> 
> const struct struct flexcan_ram_init ram_init[] {
> 	void __iomem *reg;
> 	u16 len;
> } = {
> 	{
> 		.reg = regs->mb,	/* MB RAM */
> 		.len = sizeof(regs->mb), / sizeof(u32),
> 	}, {
> 		.reg = regs->rximr,	/* RXIMR RAM */
> 		.len = sizeof(regs->rximr),
> 	}, {
> 		...
> 	},
> };

In this version, I only initialize the implemented memory, so that it's a several trivial memory slice, reserved memory not initialized. Follow your point, I need create a global pointer for struct flexcan_reg,
i.e. static struct flexcan_regs *reg, so that we can use .reg = regs->mb in ram_init[], IMHO, I don't quite want to add this, or is there any better solution to get the reg/len value?

According to below notes and discussed with IP owner before, reserved memory also can be initialized. So I want to add two memory regions, and initialize them together,
this could be more clean. I will send out a V2, please let me know which one do you think is better?

"CTRL2[WRMFRZ] grants write access to all memory positions that require initialization, ranging from 0x080 to 0xADF and from 0xF28 to 0xFFF when the CAN FD feature is
enabled. The RXMGMASK, RX14MASK, RX15MASK, and RXFGMASK registers need to be initialized as well. MCR[RFEN] must not be set during memory initialization."

Best Regards,
Joakim Zhang


  parent reply	other threads:[~2020-09-27  8:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25 15:10 [PATCH linux-can-next/flexcan 0/4] patch set for flexcan Joakim Zhang
2020-09-25 15:10 ` [PATCH linux-can-next/flexcan 1/4] can: flexcan: initialize all flexcan memory for ECC function Joakim Zhang
2020-09-25  7:29   ` Marc Kleine-Budde
2020-09-25  7:49     ` Joakim Zhang
2020-09-27  8:01     ` Joakim Zhang [this message]
2020-09-27 19:56       ` Marc Kleine-Budde
2020-09-28  2:27         ` Joakim Zhang
2020-09-28  7:01           ` Marc Kleine-Budde
2020-09-28  7:58             ` Joakim Zhang
2020-09-28  8:20               ` Marc Kleine-Budde
2020-09-28  8:36                 ` Joakim Zhang
2020-09-28  8:38                   ` Marc Kleine-Budde
2020-09-25  7:33   ` Marc Kleine-Budde
2020-09-25  7:38     ` Joakim Zhang
2020-09-25  8:11       ` Marc Kleine-Budde
2020-09-25  8:51         ` Joakim Zhang
2020-09-25  9:03           ` Marc Kleine-Budde
2020-09-25  9:09             ` Joakim Zhang
2020-09-25  9:13               ` Marc Kleine-Budde
2020-09-25 15:10 ` [PATCH linux-can-next/flexcan 2/4] can: flexcan: add flexcan driver for i.MX8MP Joakim Zhang
2020-09-25  7:36   ` Marc Kleine-Budde
2020-09-25  7:42     ` Joakim Zhang
2020-09-25  9:04   ` Marc Kleine-Budde
2020-09-25  9:11     ` Joakim Zhang
2020-09-25  9:35       ` Marc Kleine-Budde
2020-09-25  9:48         ` Joakim Zhang
2020-09-25  9:57           ` Marc Kleine-Budde
2020-09-25 15:10 ` [PATCH linux-can-next/flexcan 3/4] can: flexcan: add CAN wakeup function for i.MX8 Joakim Zhang
2020-09-25  9:44   ` Marc Kleine-Budde
2020-09-25  9:49     ` Joakim Zhang
2020-09-29 10:48   ` Marc Kleine-Budde
2020-09-25 15:10 ` [PATCH linux-can-next/flexcan 4/4] can: flexcan: disable runtime PM if register flexcandev failed Joakim Zhang

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=DB8PR04MB6795C88B839FE5083283E157E6340@DB8PR04MB6795.eurprd04.prod.outlook.com \
    --to=qiangqing.zhang@nxp.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).