netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] can: mcp251xfd: use regmap_bulk_write for compatibility
@ 2021-01-22  3:02 Su Yanjun
  2021-01-22  7:26 ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Su Yanjun @ 2021-01-22  3:02 UTC (permalink / raw)
  To: mkl, manivannan.sadhasivam, thomas.kopp, wg, davem, kuba,
	lgirdwood, broonie
  Cc: linux-can, netdev, linux-kernel, Su Yanjun

Recently i use mcp2518fd on 4.x kernel which multiple write is not
backported, regmap_raw_write will cause old kernel crash because the
tx buffer in driver is smaller then 2K. Use regmap_bulk_write instead
for compatibility.

Signed-off-by: Su Yanjun <suyanjun218@gmail.com>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index 3dde52669343..ab8aad0a7594 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -932,6 +932,7 @@ static int mcp251xfd_chip_ecc_init(struct mcp251xfd_priv *priv)
 	void *ram;
 	u32 val = 0;
 	int err;
+	int val_bytes = regmap_get_val_bytes(priv->map_reg);
 
 	ecc->ecc_stat = 0;
 
@@ -947,8 +948,8 @@ static int mcp251xfd_chip_ecc_init(struct mcp251xfd_priv *priv)
 	if (!ram)
 		return -ENOMEM;
 
-	err = regmap_raw_write(priv->map_reg, MCP251XFD_RAM_START, ram,
-			       MCP251XFD_RAM_SIZE);
+	err = regmap_bulk_write(priv->map_reg, MCP251XFD_RAM_START, ram,
+			       MCP251XFD_RAM_SIZE / val_bytes);
 	kfree(ram);
 
 	return err;
-- 
2.25.1


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

* Re: [PATCH v1] can: mcp251xfd: use regmap_bulk_write for compatibility
  2021-01-22  3:02 [PATCH v1] can: mcp251xfd: use regmap_bulk_write for compatibility Su Yanjun
@ 2021-01-22  7:26 ` Marc Kleine-Budde
  2021-01-22  7:59   ` Su
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2021-01-22  7:26 UTC (permalink / raw)
  To: Su Yanjun, manivannan.sadhasivam, thomas.kopp, wg, davem, kuba,
	lgirdwood, broonie
  Cc: linux-can, netdev, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 865 bytes --]

On 1/22/21 4:02 AM, Su Yanjun wrote:
> Recently i use mcp2518fd on 4.x kernel which multiple write is not
> backported, regmap_raw_write will cause old kernel crash because the
> tx buffer in driver is smaller then 2K. Use regmap_bulk_write instead
> for compatibility.

Hmmm, this patch will never be backported to any 4.x kernel, as the driver is
not available on these kernels. You have to carry patches for these kernels
anyway, so I think I'll not take that patch. Sorry. Drop me a note if you are
interested in updating your kernel to a recent v5.11 kernel.

regards,
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: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v1] can: mcp251xfd: use regmap_bulk_write for compatibility
  2021-01-22  7:26 ` Marc Kleine-Budde
@ 2021-01-22  7:59   ` Su
  2021-01-22  8:14     ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Su @ 2021-01-22  7:59 UTC (permalink / raw)
  To: Marc Kleine-Budde, manivannan.sadhasivam, thomas.kopp, wg, davem,
	kuba, lgirdwood, broonie
  Cc: linux-can, netdev, linux-kernel


在 2021/1/22 下午3:26, Marc Kleine-Budde 写道:
> On 1/22/21 4:02 AM, Su Yanjun wrote:
>> Recently i use mcp2518fd on 4.x kernel which multiple write is not
>> backported, regmap_raw_write will cause old kernel crash because the
>> tx buffer in driver is smaller then 2K. Use regmap_bulk_write instead
>> for compatibility.
> Hmmm, this patch will never be backported to any 4.x kernel, as the driver is
> not available on these kernels. You have to carry patches for these kernels
> anyway, so I think I'll not take that patch. Sorry. Drop me a note if you are
> interested in updating your kernel to a recent v5.11 kernel.

I got it. I have already port it to 4.x kernel. I just want anyone 
working on old kernels to use the driver more easier.

Thanks.

>
> regards,
> Marc
>

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

* Re: [PATCH v1] can: mcp251xfd: use regmap_bulk_write for compatibility
  2021-01-22  7:59   ` Su
@ 2021-01-22  8:14     ` Marc Kleine-Budde
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2021-01-22  8:14 UTC (permalink / raw)
  To: Su, manivannan.sadhasivam, thomas.kopp, wg, davem, kuba,
	lgirdwood, broonie
  Cc: linux-can, netdev, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1182 bytes --]

On 1/22/21 8:59 AM, Su wrote:
> 
> 在 2021/1/22 下午3:26, Marc Kleine-Budde 写道:
>> On 1/22/21 4:02 AM, Su Yanjun wrote:
>>> Recently i use mcp2518fd on 4.x kernel which multiple write is not
>>> backported, regmap_raw_write will cause old kernel crash because the
>>> tx buffer in driver is smaller then 2K. Use regmap_bulk_write instead
>>> for compatibility.
>> Hmmm, this patch will never be backported to any 4.x kernel, as the driver is
>> not available on these kernels. You have to carry patches for these kernels
>> anyway, so I think I'll not take that patch. Sorry. Drop me a note if you are
>> interested in updating your kernel to a recent v5.11 kernel.
> 
> I got it. I have already port it to 4.x kernel. I just want anyone 
> working on old kernels to use the driver more easier.

Ok, you can post a link yo your repo with the patches for the interested reader.

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: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2021-01-22  8:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22  3:02 [PATCH v1] can: mcp251xfd: use regmap_bulk_write for compatibility Su Yanjun
2021-01-22  7:26 ` Marc Kleine-Budde
2021-01-22  7:59   ` Su
2021-01-22  8:14     ` Marc Kleine-Budde

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).