All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] can: m_can: m_can_platform: Fix iomap_read_fifo() and iomap_write_fifo()
@ 2021-09-20 12:26 Aswath Govindraju
  2021-09-20 12:27 ` Aswath Govindraju
  0 siblings, 1 reply; 4+ messages in thread
From: Aswath Govindraju @ 2021-09-20 12:26 UTC (permalink / raw)
  Cc: Lokesh Vutla, Aswath Govindraju, Chandrasekar Ramakrishnan,
	Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Jakub Kicinski, Matt Kline, linux-can, netdev, linux-kernel

The read an writes from the fifo are from a buffer with various fields and
data at predefined offsets. So, they reads and writes should not be done to
the same address(or port) in case of val_count greater than 1. Therefore,
fix this by using iowrite32/ioread32 instead of ioread32_rep/iowrite32_rep.

Also, the write into fifo must be performed with an offset from the message
ram base address. Therefore, fix the base address to mram_base.

Fixes: e39381770ec9 ("can: m_can: Disable IRQs on FIFO bus errors")
Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
---
 drivers/net/can/m_can/m_can_platform.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index 308d4f2fff00..eee47bad0592 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -32,8 +32,13 @@ static u32 iomap_read_reg(struct m_can_classdev *cdev, int reg)
 static int iomap_read_fifo(struct m_can_classdev *cdev, int offset, void *val, size_t val_count)
 {
 	struct m_can_plat_priv *priv = cdev_to_priv(cdev);
+	void __iomem *src = priv->mram_base + offset;
 
-	ioread32_rep(priv->mram_base + offset, val, val_count);
+	while (val_count--) {
+		*(unsigned int *)val = ioread32(src);
+		val += 4;
+		src += 4;
+	}
 
 	return 0;
 }
@@ -51,8 +56,13 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
 			    const void *val, size_t val_count)
 {
 	struct m_can_plat_priv *priv = cdev_to_priv(cdev);
+	void __iomem *dst = priv->mram_base + offset;
 
-	iowrite32_rep(priv->base + offset, val, val_count);
+	while (val_count--) {
+		iowrite32(*(unsigned int *)val, dst);
+		val += 4;
+		dst += 4;
+	}
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] can: m_can: m_can_platform: Fix iomap_read_fifo() and iomap_write_fifo()
  2021-09-20 12:26 [PATCH] can: m_can: m_can_platform: Fix iomap_read_fifo() and iomap_write_fifo() Aswath Govindraju
@ 2021-09-20 12:27 ` Aswath Govindraju
  0 siblings, 0 replies; 4+ messages in thread
From: Aswath Govindraju @ 2021-09-20 12:27 UTC (permalink / raw)
  Cc: Lokesh Vutla, Chandrasekar Ramakrishnan, Wolfgang Grandegger,
	Marc Kleine-Budde, David S. Miller, Jakub Kicinski, Matt Kline,
	linux-can, netdev, linux-kernel

Hi all,

On 20/09/21 5:56 pm, Aswath Govindraju wrote:
> The read an writes from the fifo are from a buffer with various fields and
> data at predefined offsets. So, they reads and writes should not be done to
> the same address(or port) in case of val_count greater than 1. Therefore,
> fix this by using iowrite32/ioread32 instead of ioread32_rep/iowrite32_rep.
> 
> Also, the write into fifo must be performed with an offset from the message
> ram base address. Therefore, fix the base address to mram_base.
> 
> Fixes: e39381770ec9 ("can: m_can: Disable IRQs on FIFO bus errors")
> Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
> ---

Please ignore this patch sent it my mistake. Sorry for the inconvenience.

Thanks,
Aswath

>  drivers/net/can/m_can/m_can_platform.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
> index 308d4f2fff00..eee47bad0592 100644
> --- a/drivers/net/can/m_can/m_can_platform.c
> +++ b/drivers/net/can/m_can/m_can_platform.c
> @@ -32,8 +32,13 @@ static u32 iomap_read_reg(struct m_can_classdev *cdev, int reg)
>  static int iomap_read_fifo(struct m_can_classdev *cdev, int offset, void *val, size_t val_count)
>  {
>  	struct m_can_plat_priv *priv = cdev_to_priv(cdev);
> +	void __iomem *src = priv->mram_base + offset;
>  
> -	ioread32_rep(priv->mram_base + offset, val, val_count);
> +	while (val_count--) {
> +		*(unsigned int *)val = ioread32(src);
> +		val += 4;
> +		src += 4;
> +	}
>  
>  	return 0;
>  }
> @@ -51,8 +56,13 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
>  			    const void *val, size_t val_count)
>  {
>  	struct m_can_plat_priv *priv = cdev_to_priv(cdev);
> +	void __iomem *dst = priv->mram_base + offset;
>  
> -	iowrite32_rep(priv->base + offset, val, val_count);
> +	while (val_count--) {
> +		iowrite32(*(unsigned int *)val, dst);
> +		val += 4;
> +		dst += 4;
> +	}
>  
>  	return 0;
>  }
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] can: m_can: m_can_platform: Fix iomap_read_fifo() and iomap_write_fifo()
  2021-09-20 12:33 Aswath Govindraju
@ 2021-10-17 20:44 ` Marc Kleine-Budde
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2021-10-17 20:44 UTC (permalink / raw)
  To: Aswath Govindraju
  Cc: Lokesh Vutla, Chandrasekar Ramakrishnan, Wolfgang Grandegger,
	David S. Miller, Jakub Kicinski, Matt Kline, linux-can, netdev,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 952 bytes --]

On 20.09.2021 18:03:43, Aswath Govindraju wrote:
> The read and writes from the fifo are from a buffer, with various fields
> and data at predefined offsets. So, they should not be done to the same
> address(or port) in case of val_count greater than 1. Therefore, fix this
> by using iowrite32/ioread32 instead of ioread32_rep/iowrite32_rep.
> 
> Also, the write into fifo must be performed with an offset from the message
> ram base address. Therefore, fix the base address to mram_base.
> 
> Fixes: e39381770ec9 ("can: m_can: Disable IRQs on FIFO bus errors")
> Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>

Applied to linux-can/testing.

Thanks,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] can: m_can: m_can_platform: Fix iomap_read_fifo() and iomap_write_fifo()
@ 2021-09-20 12:33 Aswath Govindraju
  2021-10-17 20:44 ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Aswath Govindraju @ 2021-09-20 12:33 UTC (permalink / raw)
  Cc: Lokesh Vutla, Aswath Govindraju, Chandrasekar Ramakrishnan,
	Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Jakub Kicinski, Matt Kline, linux-can, netdev, linux-kernel

The read and writes from the fifo are from a buffer, with various fields
and data at predefined offsets. So, they should not be done to the same
address(or port) in case of val_count greater than 1. Therefore, fix this
by using iowrite32/ioread32 instead of ioread32_rep/iowrite32_rep.

Also, the write into fifo must be performed with an offset from the message
ram base address. Therefore, fix the base address to mram_base.

Fixes: e39381770ec9 ("can: m_can: Disable IRQs on FIFO bus errors")
Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
---
 drivers/net/can/m_can/m_can_platform.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index 308d4f2fff00..eee47bad0592 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -32,8 +32,13 @@ static u32 iomap_read_reg(struct m_can_classdev *cdev, int reg)
 static int iomap_read_fifo(struct m_can_classdev *cdev, int offset, void *val, size_t val_count)
 {
 	struct m_can_plat_priv *priv = cdev_to_priv(cdev);
+	void __iomem *src = priv->mram_base + offset;
 
-	ioread32_rep(priv->mram_base + offset, val, val_count);
+	while (val_count--) {
+		*(unsigned int *)val = ioread32(src);
+		val += 4;
+		src += 4;
+	}
 
 	return 0;
 }
@@ -51,8 +56,13 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
 			    const void *val, size_t val_count)
 {
 	struct m_can_plat_priv *priv = cdev_to_priv(cdev);
+	void __iomem *dst = priv->mram_base + offset;
 
-	iowrite32_rep(priv->base + offset, val, val_count);
+	while (val_count--) {
+		iowrite32(*(unsigned int *)val, dst);
+		val += 4;
+		dst += 4;
+	}
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-17 20:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 12:26 [PATCH] can: m_can: m_can_platform: Fix iomap_read_fifo() and iomap_write_fifo() Aswath Govindraju
2021-09-20 12:27 ` Aswath Govindraju
2021-09-20 12:33 Aswath Govindraju
2021-10-17 20:44 ` Marc Kleine-Budde

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.