Re: [PATCH v4 3/5] net: can: flexcan: split the Message Buffer RAM area

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/12/2018 06:14 PM, Pankaj Bansal wrote:
> The message buffer RAM area is not a contiguous 1KB area but 2 partitions
> of 512 bytes each. Till now, we used Message buffers with payload size 8
> bytes, which translates to 32 MBs per partition and no spare space is left
> in any partition.
> However, in upcoming SOC LX2160A the message buffers can have payload size
> 64 bytes. This results in less than 32 MBs per partition and some empty
> area is left at the end of each partition.This empty area should not be
> accessed.
> Therefore, split the Message Buffer RAM area into two partitions.
> 
> Signed-off-by: Pankaj Bansal <pankaj.bansal@xxxxxxx>
> ---
> 
> Notes:
>     V4:
>      - Make regs->mb to 2D array
>      - use bank terminology instead of block in flexcan_get_mb
>     V3:
>      - No change
>     V2:
>      - removed mb_count_block1 and mb_count_block2 from priv structure due to
>        flexcan_get_mb function introduced in earlier patch
> 
>  drivers/net/can/flexcan.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index 8c7f96f29118..3106134f3ba4 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
> @@ -224,7 +224,7 @@ struct flexcan_regs {
>  	u32 rxfgmask;		/* 0x48 */
>  	u32 rxfir;		/* 0x4c */
>  	u32 _reserved3[12];	/* 0x50 */
> -	u8  mb[1024];		/* 0x80 */
> +	u8 mb[2][512];		/* 0x80 */
>  	/* FIFO-mode:
>  	 *			MB
>  	 * 0x080...0x08f	0	RX message buffer
> @@ -358,6 +358,8 @@ static struct flexcan_mb *flexcan_get_mb(const struct flexcan_priv *priv,
>  					 u8 mb_index)
>  {
>  	u8 mb_size;
> +	u8 mb_count_bank;
> +	bool bank;
>  
>  	if (WARN_ON(mb_index >= priv->mb_count))
>  		return NULL;
> @@ -367,8 +369,13 @@ static struct flexcan_mb *flexcan_get_mb(const struct flexcan_priv *priv,
>  	else
>  		mb_size = sizeof(struct flexcan_mb) + CAN_MAX_DLEN;
>  
> +	mb_count_bank = sizeof(priv->regs->mb[0]) / mb_size;
> +
> +	bank = mb_index >= mb_count_bank;
> +	mb_index -= (bank ? mb_count_bank : 0);

	if (bank)
		mb_index -= mb_count_bank;

> +
>  	return (struct flexcan_mb __iomem *)
> -		(&priv->regs->mb[mb_size * mb_index]);
> +		(&priv->regs->mb[bank][mb_size * mb_index]);
>  }
>  
>  static inline void flexcan_error_irq_enable(const struct flexcan_priv *priv)
> @@ -1147,7 +1154,8 @@ static int flexcan_open(struct net_device *dev)
>  		mb_size = sizeof(struct flexcan_mb) + CANFD_MAX_DLEN;
>  	else
>  		mb_size = sizeof(struct flexcan_mb) + CAN_MAX_DLEN;
> -	priv->mb_count = sizeof(priv->regs->mb) / mb_size;
> +	priv->mb_count = sizeof(priv->regs->mb[0]) / mb_size;
> +	priv->mb_count += sizeof(priv->regs->mb[1]) / mb_size;

	priv->mb_count = sizeof(priv->regs->mb[0]) / mb_size +
			 sizeof(priv->regs->mb[1]) / mb_size;

>  
>  	if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) {
>  		priv->tx_mb_idx = FLEXCAN_TX_MB_OFF_TIMESTAMP;
> 

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: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux