From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Dong Aisheng <b29396@freescale.com>, linux-can@vger.kernel.org
Cc: wg@grandegger.com, varkabhadram@gmail.com,
netdev@vger.kernel.org, socketcan@hartkopp.net,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V4 3/3] can: m_can: add missing message RAM initialization
Date: Fri, 07 Nov 2014 11:30:38 +0100 [thread overview]
Message-ID: <545C9F4E.3040901@pengutronix.de> (raw)
In-Reply-To: <1415349914-9145-3-git-send-email-b29396@freescale.com>
[-- Attachment #1: Type: text/plain, Size: 2285 bytes --]
On 11/07/2014 09:45 AM, Dong Aisheng wrote:
> The M_CAN message RAM is usually equipped with a parity or ECC functionality.
> But RAM cells suffer a hardware reset and can therefore hold arbitrary
> content at startup - including parity and/or ECC bits.
>
> To prevent the M_CAN controller detecting checksum errors when reading
> potentially uninitialized TX message RAM content to transmit CAN
> frames the TX message RAM has to be written with (any kind of) initial
> data.
>
> Signed-off-by: Dong Aisheng <b29396@freescale.com>
> ---
> ChangeLog:
> v3-v4:
> * initialize the entire Message RAM in use instead of only 8 bytes
> since this is a valid and needed initialization process.
> Patch title also changed.
> ---
> drivers/net/can/m_can/m_can.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index eee1533..de742d0 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -1114,7 +1114,7 @@ static int m_can_of_parse_mram(struct platform_device *pdev,
> struct resource *res;
> void __iomem *addr;
> u32 out_val[MRAM_CFG_LEN];
> - int ret;
> + int i, start, end, ret;
>
> /* message ram could be shared */
> res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram");
> @@ -1165,6 +1165,15 @@ static int m_can_of_parse_mram(struct platform_device *pdev,
> priv->mcfg[MRAM_TXE].off, priv->mcfg[MRAM_TXE].num,
> priv->mcfg[MRAM_TXB].off, priv->mcfg[MRAM_TXB].num);
>
> + /* initialize the entire Message RAM in use to avoid possible
> + * ECC/parity checksum errors when reading an uninitialized buffer
> + */
> + start = priv->mcfg[MRAM_SIDF].off;
> + end = priv->mcfg[MRAM_TXB].off +
> + priv->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE;
> + for (i = start; i < end; i += 4)
> + writel(0x0, priv->mram_base + i);
Can we access the mram without turning on the clock?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: mkl@pengutronix.de (Marc Kleine-Budde)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V4 3/3] can: m_can: add missing message RAM initialization
Date: Fri, 07 Nov 2014 11:30:38 +0100 [thread overview]
Message-ID: <545C9F4E.3040901@pengutronix.de> (raw)
In-Reply-To: <1415349914-9145-3-git-send-email-b29396@freescale.com>
On 11/07/2014 09:45 AM, Dong Aisheng wrote:
> The M_CAN message RAM is usually equipped with a parity or ECC functionality.
> But RAM cells suffer a hardware reset and can therefore hold arbitrary
> content at startup - including parity and/or ECC bits.
>
> To prevent the M_CAN controller detecting checksum errors when reading
> potentially uninitialized TX message RAM content to transmit CAN
> frames the TX message RAM has to be written with (any kind of) initial
> data.
>
> Signed-off-by: Dong Aisheng <b29396@freescale.com>
> ---
> ChangeLog:
> v3-v4:
> * initialize the entire Message RAM in use instead of only 8 bytes
> since this is a valid and needed initialization process.
> Patch title also changed.
> ---
> drivers/net/can/m_can/m_can.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index eee1533..de742d0 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -1114,7 +1114,7 @@ static int m_can_of_parse_mram(struct platform_device *pdev,
> struct resource *res;
> void __iomem *addr;
> u32 out_val[MRAM_CFG_LEN];
> - int ret;
> + int i, start, end, ret;
>
> /* message ram could be shared */
> res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram");
> @@ -1165,6 +1165,15 @@ static int m_can_of_parse_mram(struct platform_device *pdev,
> priv->mcfg[MRAM_TXE].off, priv->mcfg[MRAM_TXE].num,
> priv->mcfg[MRAM_TXB].off, priv->mcfg[MRAM_TXB].num);
>
> + /* initialize the entire Message RAM in use to avoid possible
> + * ECC/parity checksum errors when reading an uninitialized buffer
> + */
> + start = priv->mcfg[MRAM_SIDF].off;
> + end = priv->mcfg[MRAM_TXB].off +
> + priv->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE;
> + for (i = start; i < end; i += 4)
> + writel(0x0, priv->mram_base + i);
Can we access the mram without turning on the clock?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141107/23c5ba16/attachment.sig>
next prev parent reply other threads:[~2014-11-07 10:30 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-07 8:45 [PATCH V4 1/3] can: add can_is_canfd_skb() API Dong Aisheng
2014-11-07 8:45 ` Dong Aisheng
2014-11-07 8:45 ` Dong Aisheng
2014-11-07 8:45 ` [PATCH V4 2/3] can: m_can: update to support CAN FD features Dong Aisheng
2014-11-07 8:45 ` Dong Aisheng
2014-11-07 8:45 ` Dong Aisheng
2014-11-13 10:10 ` Marc Kleine-Budde
2014-11-13 10:10 ` Marc Kleine-Budde
2014-11-13 16:56 ` Oliver Hartkopp
2014-11-13 16:56 ` Oliver Hartkopp
2014-11-14 9:24 ` Marc Kleine-Budde
2014-11-14 9:24 ` Marc Kleine-Budde
2014-11-18 11:22 ` Dong Aisheng
2014-11-18 11:22 ` Dong Aisheng
2014-11-18 11:22 ` Dong Aisheng
2014-11-07 8:45 ` [PATCH V4 3/3] can: m_can: add missing message RAM initialization Dong Aisheng
2014-11-07 8:45 ` Dong Aisheng
2014-11-07 8:45 ` Dong Aisheng
2014-11-07 10:30 ` Marc Kleine-Budde [this message]
2014-11-07 10:30 ` Marc Kleine-Budde
2014-11-07 10:21 ` Dong Aisheng
2014-11-07 10:21 ` Dong Aisheng
2014-11-07 10:21 ` Dong Aisheng
2014-11-07 11:53 ` Oliver Hartkopp
2014-11-07 11:53 ` Oliver Hartkopp
2014-11-13 10:04 ` [PATCH V4 1/3] can: add can_is_canfd_skb() API Marc Kleine-Budde
2014-11-13 10:04 ` Marc Kleine-Budde
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=545C9F4E.3040901@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=b29396@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-can@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=socketcan@hartkopp.net \
--cc=varkabhadram@gmail.com \
--cc=wg@grandegger.com \
/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.