lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251121-abiding-meek-bustard-187f63-mkl@pengutronix.de>
Date: Fri, 21 Nov 2025 12:00:31 +0100
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Arun Muthusamy <arun.muthusamy@...sler.com>
Cc: robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org, 
	mailhol@...nel.org, devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-can@...r.kernel.org, Daniel Hellstrom <daniel@...sler.com>
Subject: Re: [PATCH 06/10] can: grcan: optimize DMA by 32-bit accesses

On 18.11.2025 10:21:11, Arun Muthusamy wrote:
> From: Daniel Hellstrom <daniel@...sler.com>
>
> Optimizes DMA transfers in the GRCAN driver by reorganizing
> data handling to use 32-bit accesses instead of individual
> byte accesses.
>
> Signed-off-by: Arun Muthusamy <arun.muthusamy@...sler.com>
> Signed-off-by: Daniel Hellstrom <daniel@...sler.com>
> ---
>  drivers/net/can/grcan.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
> index b9b0dd7d53f6..e367581faa57 100644
> --- a/drivers/net/can/grcan.c
> +++ b/drivers/net/can/grcan.c
> @@ -1287,7 +1287,7 @@ static int grcan_receive(struct net_device *dev, int budget)
>  	struct sk_buff *skb;
>  	u32 wr, rd, startrd;
>  	u32 *slot;
> -	u32 i, rtr, eff, j, shift;
> +	u32 rtr, eff;
>  	int work_done = 0;
>
>  	rd = grcan_read_reg(&regs->rxrd);
> @@ -1323,10 +1323,10 @@ static int grcan_receive(struct net_device *dev, int budget)
>  		if (rtr) {
>  			cf->can_id |= CAN_RTR_FLAG;
>  		} else {
> -			for (i = 0; i < cf->len; i++) {
> -				j = GRCAN_MSG_DATA_SLOT_INDEX(i);
> -				shift = GRCAN_MSG_DATA_SHIFT(i);
> -				cf->data[i] = (u8)(slot[j] >> shift);
> +			if (cf->can_dlc > 0) {
> +				*(u32 *)(cf->data) = slot[2];
> +				if (cf->can_dlc > 4)
> +					*(u32 *)(cf->data + 4) = slot[3];

Can you can use memcpy() for this?

>  			}

>
>  			stats->rx_bytes += cf->len;
> @@ -1466,8 +1466,7 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *skb,
>  	u32 id, txwr, txrd, space, txctrl;
>  	int slotindex;
>  	u32 *slot;
> -	u32 i, rtr, eff, dlc, tmp, err;
> -	int j, shift;
> +	u32 rtr, eff, dlc, tmp, err;
>  	unsigned long flags;
>  	u32 oneshotmode = priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT;
>
> @@ -1520,10 +1519,10 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *skb,
>  	slot[1] = ((dlc << GRCAN_MSG_DLC_BIT) & GRCAN_MSG_DLC);
>  	slot[2] = 0;
>  	slot[3] = 0;
> -	for (i = 0; i < dlc; i++) {
> -		j = GRCAN_MSG_DATA_SLOT_INDEX(i);
> -		shift = GRCAN_MSG_DATA_SHIFT(i);
> -		slot[j] |= cf->data[i] << shift;
> +	if (dlc > 0) {
> +		slot[2] = *(u32 *)(cf->data); /* data aligned 64-bit */
> +		if (dlc > 4)
> +			slot[3] = *(u32 *)(cf->data + 4);

Can you can use memcpy() for this?

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ