Re: [PATCH 07/10] can: grcan: set DMA mask for GRCAN and GRCANFD to 32-bit

From: Marc Kleine-Budde

Date: Fri Nov 21 2025 - 07:47:02 EST


On 18.11.2025 10:21:12, Arun Muthusamy wrote:
> From: Daniel Hellstrom <daniel@xxxxxxxxxxx>
>
> Sets the DMA mask for GRCAN and GRCANFD devices to 32-bit.
> Setting the DMA mask and coherent DMA mask to 32-bit ensures proper
> memory addressing during DMA operations
>
> Signed-off-by: Arun Muthusamy <arun.muthusamy@xxxxxxxxxxx>
> Signed-off-by: Daniel Hellstrom <daniel@xxxxxxxxxxx>
> ---
> drivers/net/can/grcan.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
> index e367581faa57..51a10fae2faf 100644
> --- a/drivers/net/can/grcan.c
> +++ b/drivers/net/can/grcan.c
> @@ -1074,6 +1074,12 @@ static int grcan_allocate_dma_buffers(struct net_device *dev,
>
> /* Extra GRCAN_BUFFER_ALIGNMENT to allow for alignment */
> dma->base_size = lsize + ssize + GRCAN_BUFFER_ALIGNMENT;
> +
> + /* On 64-bit systems.. GRCAN and GRCANFD can only address 32-bit */
> + if (dma_set_mask_and_coherent(priv->ofdev_dev, DMA_BIT_MASK(32))) {
> + netdev_warn(dev, "No suitable DMA available\n");
> + return -ENOMEM;

Please move this to probe(), return the error code, and use
dev_err_probe() for the error message.

regards,
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 |

Attachment: signature.asc
Description: PGP signature