Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp320425pxb; Thu, 25 Feb 2021 03:32:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrbrOXpLi2rypVCr7VGhIKYDumNg5KeTOrpNShdXqkUzQabbFBwx3aZDxGS7YBJRGD/mNM X-Received: by 2002:a50:cbc7:: with SMTP id l7mr2369571edi.134.1614252752891; Thu, 25 Feb 2021 03:32:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614252752; cv=none; d=google.com; s=arc-20160816; b=UGOp+qocfqj+k00Q4Ef7sAFdM2Cp5TamKS5nMAaBVC2Dg+SkpIZHFdG/a54QeiImjI 5Tw0APJkDzsOxBwFOBZAmGdtDLeCNKfdkFY1u+neM9GCCgnXMZ4Gt4pYz+KQiOlZEnY2 sf+I35m50N+G25j+ujsEUIytiPfpicnBKvLPkxCwTDNnwj0HIScQxF/UXA/0wGxJwTlf QedJItjPb8jxDIZ356Mvu8x7FHyFcqIWnjtCCgc7Zd+NxBP1jIGu7+1LSe6J88+yx0Nf Wh/xZkbQAz0LZjOTXYGS+/CJ76qCWUWrUBVIPqnjYSKAigfdcIKK9NMWtf+IsFJislHd MUaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=fJTk4hOSh3osgEJZtxnmuVHIsj+OOT3Hc2dqbZnzGOE=; b=DYaEHfMbXQtvmFQDk/mDlSq+2Oap6ZhP4moRkz0w5xnbMHdi99tsApsO4f1nnVOxJz SB03OakEY9uKmi3K/BBKW5FDDmGQezn23BX+dfSH5iSzmuwsDD4E4w/IfKVxDGl8fEV6 z7RzMHFCdBnzBz9D1DMnn+V1PPWLxN6BVl79AJbZLnx4pQoE94eIQL5EWh/xENIy2Z1E JWLdSBPiABLWK6BEV/pfE492x7sDtGrhcpFKOKwbQQ6Bqjnvm72Amgaf530f8s3AfVyx HnWLdBwBHsD8PAokJ4Wy2XBcTFtbSTw1Q+epirWqsx4A+gugk0GOvwy5zhbK+GaVUxA7 tqXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p13si2961496edq.148.2021.02.25.03.32.09; Thu, 25 Feb 2021 03:32:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232982AbhBYHYo (ORCPT + 99 others); Thu, 25 Feb 2021 02:24:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232417AbhBYHYL (ORCPT ); Thu, 25 Feb 2021 02:24:11 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CCCCC061786 for ; Wed, 24 Feb 2021 23:23:31 -0800 (PST) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lFAzP-000525-RF; Thu, 25 Feb 2021 08:23:11 +0100 Received: from pengutronix.de (unknown [IPv6:2a03:f580:87bc:d400:55fd:a17b:b4ca:d5fb]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 5AF8A5E8D3D; Thu, 25 Feb 2021 07:23:07 +0000 (UTC) Date: Thu, 25 Feb 2021 08:23:06 +0100 From: Marc Kleine-Budde To: Dario Binacchi Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , YueHaibing , Zhang Qilong , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 5/6] can: c_can: prepare to up the message objects number Message-ID: <20210225072306.wdxtzbpowuorhxlp@pengutronix.de> References: <20210224225246.11346-1-dariobin@libero.it> <20210224225246.11346-6-dariobin@libero.it> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4ncm4fr4jlmweoy3" Content-Disposition: inline In-Reply-To: <20210224225246.11346-6-dariobin@libero.it> X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --4ncm4fr4jlmweoy3 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey Dario, just a quick note... On 24.02.2021 23:52:45, Dario Binacchi wrote: > -struct net_device *alloc_c_can_dev(void) > +struct net_device *alloc_c_can_dev(int msg_obj_num) > { > struct net_device *dev; > struct c_can_priv *priv; > + int msg_obj_tx_num =3D msg_obj_num / 2; > =20 > - dev =3D alloc_candev(sizeof(struct c_can_priv), C_CAN_MSG_OBJ_TX_NUM); > + dev =3D alloc_candev(sizeof(struct c_can_priv), msg_obj_tx_num); > if (!dev) > return NULL; > =20 > priv =3D netdev_priv(dev); > - netif_napi_add(dev, &priv->napi, c_can_poll, C_CAN_NAPI_WEIGHT); > + priv->msg_obj_num =3D msg_obj_num; > + priv->msg_obj_rx_num =3D msg_obj_num - msg_obj_tx_num; > + priv->msg_obj_rx_first =3D 1; > + priv->msg_obj_rx_last =3D > + priv->msg_obj_rx_first + priv->msg_obj_rx_num - 1; > + priv->msg_obj_rx_mask =3D ((u64)1 << priv->msg_obj_rx_num) - 1; > + > + priv->msg_obj_tx_num =3D msg_obj_tx_num; > + priv->msg_obj_tx_first =3D priv->msg_obj_rx_last + 1; > + priv->msg_obj_tx_last =3D > + priv->msg_obj_tx_first + priv->msg_obj_tx_num - 1; > + > + priv->dlc =3D kcalloc(msg_obj_tx_num, sizeof(*priv->dlc), GFP_KERNEL); You can pass a larger size to alloc_candev() so that it includes the mem you allocate here. > + if (!priv->dlc) { > + free_candev(dev); > + return NULL; > + } > + > + netif_napi_add(dev, &priv->napi, c_can_poll, priv->msg_obj_rx_num); Marc --=20 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 | --4ncm4fr4jlmweoy3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEK3kIWJt9yTYMP3ehqclaivrt76kFAmA3UFcACgkQqclaivrt 76niVAf+IuzAhvFFvjMtVPcuWVBVvHIiEbAaTPfc40isqqtmuoIsiBv1sttYFzFn A6IiBdAZZgJL+x4TEFbXjOrC+0YHxwL2YIovO7tiZGy98lH0BV4eYRguvmKunm5H fEH0wHc4Ouw1pSYypUFnVia9UoYB16Npubs6tdipw8bo6IAGWo7LRUlEH1fHvWYP l9WzqzD0Ywq2tsYvdOuhuo7A7IqwR7FxXTUEwNsLs0mSFdNDOm5t0QLSAv9Q1we7 nNUvfG563VS4f3lBfLny99Ytd+HCprXDfnIBEetrJqDvzk/b7fpyUpGcmNXjVpJe 9PMUlZWuDN6jS22dO2RETQ1Gi5ip5Q== =pUEf -----END PGP SIGNATURE----- --4ncm4fr4jlmweoy3--