From patchwork Tue Mar 2 21:54:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 393407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84117C2BA14 for ; Wed, 3 Mar 2021 04:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AC6764ECF for ; Wed, 3 Mar 2021 04:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1838187AbhCCEHY (ORCPT ); Tue, 2 Mar 2021 23:07:24 -0500 Received: from smtp-17-i2.italiaonline.it ([213.209.12.17]:33875 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2359512AbhCBWAY (ORCPT ); Tue, 2 Mar 2021 17:00:24 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id HCz0lBDmUlChfHCz9lGZyy; Tue, 02 Mar 2021 22:55:19 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614722119; bh=qdqprpCrTgqGjjL1MPD2Trs9CbuR4PMIgLdSlLVKd3w=; h=From; b=s7EJYlgnGzzV4Ryga4AqcroedD4vs9eeUDk6FVtDA4XEPrjWvajfER68wFp56kdB5 FbNtq+/QO/fxgMHqYuYSlSdqUOk2yoN/4io0NDmOLsidK0oIpzpl8Knv34Op405RcY Mp/qsUhjx7e8LjvMQMMlGkwnzXQRyKP4+Iifk1j+0IEAMd/qzeTzXv1l2wtQaCr171 vi+c4/uvV4c+JZwg8P0OOeihm28Tey1nPIc9MF47EG1JxfnNg0KIqeYnx4gv3g79FN e8fUnRK8cdTK043DaEGv9XWbEMJr9L1k9zsVHxVVl5z+yuDWEE2Z3DmO6uHEI2U8fO nWtcEhHhkY9wg== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=603eb447 cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=sBSmD8KNhItU_oXWusYA:9 From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Alexander Stein , Federico Vaga , Dario Binacchi , "David S. Miller" , Jakub Kicinski , Marc Kleine-Budde , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , YueHaibing , Zhang Qilong , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 1/6] can: c_can: remove unused code Date: Tue, 2 Mar 2021 22:54:30 +0100 Message-Id: <20210302215435.18286-2-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210302215435.18286-1-dariobin@libero.it> References: <20210302215435.18286-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfCNlwnz3gfkmh0/i+idqmVXV3IC5zhju5NcNjmP77+0Sy4O0/i5t7BHkMNi08XyPTlPv2sB4vCqUCvz/7ifRdCVVcAqVLLovQAbiOld/IqVqy++PRsNH LPWSEUzarsR2z4SFq/slAp18rS+7kp+XCGL9PnM99yB2EMRB2daQsNPaEI+yzen7u/lXxMzJzAldven4Y4oa+tKcKW4/C3u8m5mSi2i6szDAmRjDlsEJKGyJ 03YdaVENCNeYo9GLMo34CTVOXBgRSyAZPqO3I/GXKJ7wHYOncGVN2jboI2nykNmhfT3LT/9xcpIJPWRKcs7xI4ia2+Mct40avnilfc4/60a0AdkvPTiKicyS Wq8jwC6oz9WkLnzjUlvT4aChXKS64mBDsACwJa5TLcJYMYh/U82FrLKxMSSZsuo4wTMyrgPYVCQa/ydDeyzzqd4rRV7peiMsn23y2Z67Dd9GaLz1IovrFcDS f09PwDeJb3LwU0l7fU21iTrIn8AciGYg52U5d3Fp26ljIIoPiwZhOW1D6IIP48nks3/LORWGTsODxyhCmPKMqmx0Vpfslhvrt8D4KK71UhRv9C02zFfqvAAU ID1aS29j/z0D3Mcz0yT39OKFStf2wS9nkou1EcYUe5Z36VN8/N6tyTBHZD5Oz2Mhmnb8f06qtymwzmHbwauXc58oooXHW3IkBoPM/ovqnURybA== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit 9d23a9818cb1 ("can: c_can: Remove unused inline function") left behind C_CAN_MSG_OBJ_TX_LAST constant. Commit fa39b54ccf28 ("can: c_can: Get rid of pointless interrupts") left behind C_CAN_MSG_RX_LOW_LAST and C_CAN_MSG_OBJ_RX_SPLIT constants. The removed code also made a comment useless and misleading. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/net/can/c_can/c_can.c | 3 +-- drivers/net/can/c_can/c_can.h | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index ef474bae47a1..a962ceefd44a 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -848,8 +848,7 @@ static inline u32 c_can_get_pending(struct c_can_priv *priv) * c_can core saves a received CAN message into the first free message * object it finds free (starting with the lowest). Bits NEWDAT and * INTPND are set for this message object indicating that a new message - * has arrived. To work-around this issue, we keep two groups of message - * objects whose partitioning is defined by C_CAN_MSG_OBJ_RX_SPLIT. + * has arrived. * * We clear the newdat bit right away. * diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h index 92213d3d96eb..90d3d2e7a086 100644 --- a/drivers/net/can/c_can/c_can.h +++ b/drivers/net/can/c_can/c_can.h @@ -32,11 +32,7 @@ C_CAN_MSG_OBJ_RX_NUM - 1) #define C_CAN_MSG_OBJ_TX_FIRST (C_CAN_MSG_OBJ_RX_LAST + 1) -#define C_CAN_MSG_OBJ_TX_LAST (C_CAN_MSG_OBJ_TX_FIRST + \ - C_CAN_MSG_OBJ_TX_NUM - 1) -#define C_CAN_MSG_OBJ_RX_SPLIT 9 -#define C_CAN_MSG_RX_LOW_LAST (C_CAN_MSG_OBJ_RX_SPLIT - 1) #define RECEIVE_OBJECT_BITS 0x0000ffff enum reg { From patchwork Tue Mar 2 21:54:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 392561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 270EAC41518 for ; Wed, 3 Mar 2021 04:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBEDA64ED4 for ; Wed, 3 Mar 2021 04:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1837948AbhCCEHR (ORCPT ); Tue, 2 Mar 2021 23:07:17 -0500 Received: from smtp-17-i2.italiaonline.it ([213.209.12.17]:42085 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1837608AbhCBV6H (ORCPT ); Tue, 2 Mar 2021 16:58:07 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id HCz0lBDmUlChfHCz9lGZzj; Tue, 02 Mar 2021 22:55:20 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614722120; bh=ZwZwTipdZKxY6qGd4VuGRlxL2+9rpHSGnSFdq6NXms8=; h=From; b=mPrpEseLmRrBAvDVm04K8oNNF28Zo/O/F0qD5uEk4Up7Y3uoqdtz+zXu1AzwFIMdP j0HCZMMKK98dqhfU3IWrb8+e7iuMyJ7ki5vqiJ8gruOIvw7wErtVYCWVwFKfpzqmxp uwo1acySIN6i/2BVaKJe2jWrdOa2QNzFkZRj/anG6il33wNxYpiMSdWMnKJHppkpxf 0wIHDFZUWZB6wuI1JN4X859+j3PnCM03RmrjpUPKkPe1YArgRVpez8Gsb2TG59Tobc JAj/xle++6jY9sTNqtQaWraAT966UuBpbDaoxG9GeIuqx9UOcDpEa93ToyEJrfOoL0 PmNRkDJhakNUA== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=603eb448 cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=AkCzXzlJzD4X874_W7gA:9 From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Alexander Stein , Federico Vaga , Dario Binacchi , "David S. Miller" , Jakub Kicinski , Marc Kleine-Budde , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , YueHaibing , Zhang Qilong , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 2/6] can: c_can: fix indentation Date: Tue, 2 Mar 2021 22:54:31 +0100 Message-Id: <20210302215435.18286-3-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210302215435.18286-1-dariobin@libero.it> References: <20210302215435.18286-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfI+vjYn0/uqmevKnPg9KnLpPOBK8b83OBrdtkArRSpSR/lB1fyWXvSx1aaQaq8iD80nZa8tu9Aibepn3Zpu8XMjq659gMLR/wRhhLWws1QoHPXdOdU7t nw5q39a2Kyn0BVa6RmrJrV16o7UO0v8frA20GoiQEHGYoHIDOtCE3ui9DrOKS9VvQfqniYmpAdqgeBl0t/IfdgP4WET+0PQDGwL4Oda//5gW4VaROPl1OXYW rYXgN8JA2amTRRJDUR/jTtPofmxWKILyJj/XIOPOYHhor5mWUAHbil813bTFeK7Y7z0fwLwD5Lgs24VcbS3zyZsKc7uUt/PO8FF6of6efXqHGbL6ViTcaklM jYjoQlnTqZW0AI2PGOK1C4xOESF6WswqM7ZQXZnC4fx7BxwVb2OS49/W7pWILf+5xvO8VkLSU6+YSrrEvL6OjIaEleuxWBt+QoHxMSCiyY2giOfuei32wCSt XY7M69zaBK5x8OUTHAtZ2226g2JLAHCm7Tb+8RXIxLmYM6boE19+tr41E4U7UNk/jTH0w0SocPjoYmBumSgIMtgcllXr7pjPIyjk3yIqE3hnAqmzc7bIeRFj nFZRk21NuxG+cHREwabEZqM0/fhYh0GDeBRwBKLimBD82BvvTweiFwA52SwJfI0S7UXCdNeEuQ4qfnvO/vA27lW+6CtgHuCavBBkS1QCOfH7YA== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit 524369e2391f ("can: c_can: remove obsolete STRICT_FRAME_ORDERING Kconfig option") left behind wrong indentation, fix it. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/net/can/c_can/c_can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index a962ceefd44a..dbcc1c1c92d6 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -786,7 +786,7 @@ static u32 c_can_adjust_pending(u32 pend) static inline void c_can_rx_object_get(struct net_device *dev, struct c_can_priv *priv, u32 obj) { - c_can_object_get(dev, IF_RX, obj, priv->comm_rcv_high); + c_can_object_get(dev, IF_RX, obj, priv->comm_rcv_high); } static inline void c_can_rx_finalize(struct net_device *dev, From patchwork Tue Mar 2 21:54:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 393405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4F7EC4321A for ; Wed, 3 Mar 2021 04:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A62464E84 for ; Wed, 3 Mar 2021 04:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1838255AbhCCEHZ (ORCPT ); Tue, 2 Mar 2021 23:07:25 -0500 Received: from smtp-17.italiaonline.it ([213.209.10.17]:34988 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2359536AbhCBWAs (ORCPT ); Tue, 2 Mar 2021 17:00:48 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id HCz0lBDmUlChfHCzAlGa06; Tue, 02 Mar 2021 22:55:20 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614722120; bh=o/7ch7+V1m2CY14tyIbFbttFZQOGlpyY2sI2NtzRNWM=; h=From; b=eOxbH4FWtwkffGi8S8R3eq56ekkv0GHtv7vqYsSLRtrhSLFmpUHfOwjNyVV9Ol+RW tE668mIkBZG6nxJ40xnPpPxAKCbpsEn63tnYl3Re8hX6xEROU7F2s/89/68+XANJWT XRAgaGeVxPvdui/mvjbP86nh5SLzUjLq9zTEeSnxBjb1mIT7Lk7hA5eaznjQWNS7sZ +CEnNdsQTLyOU7BOwYq00ByDnc6DGtrGxEFjTjIUITFVraYxnQ+cheNhYDneALCJHD MGxcy/R/GY0+aRHSlX24kZ7K4V0yXTgq1aSUeLhK7I8FPfYSbNv8gcBgrJQaYt37U+ NldwJA69q6Y1Q== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=603eb448 cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=xyINcoL9mV1Qo4PShlgA:9 From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Alexander Stein , Federico Vaga , Dario Binacchi , "David S. Miller" , Jakub Kicinski , Marc Kleine-Budde , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , YueHaibing , Zhang Qilong , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 3/6] can: c_can: add a comment about IF_RX interface's use Date: Tue, 2 Mar 2021 22:54:32 +0100 Message-Id: <20210302215435.18286-4-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210302215435.18286-1-dariobin@libero.it> References: <20210302215435.18286-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfI+vjYn0/uqmevKnPg9KnLpPOBK8b83OBrdtkArRSpSR/lB1fyWXvSx1aaQaq8iD80nZa8tu9Aibepn3Zpu8XMjq659gMLR/wRhhLWws1QoHPXdOdU7t nw5q39a2Kyn0BVa6RmrJrV16o7UO0v8frA20GoiQEHGYoHIDOtCE3ui9DrOKS9VvQfqniYmpAdqgeBl0t/IfdgP4WET+0PQDGwL4Oda//5gW4VaROPl1OXYW rYXgN8JA2amTRRJDUR/jTtPofmxWKILyJj/XIOPOYHhor5mWUAHbil813bTFeK7Y7z0fwLwD5Lgs24VcbS3zyZsKc7uUt/PO8FF6of6efXqHGbL6ViTcaklM jYjoQlnTqZW0AI2PGOK1C4xOESF6WswqM7ZQXZnC4fx7BxwVb2OS49/W7pWILf+5xvO8VkLSU6+YSrrEvL6OjIaEleuxWBt+QoHxMSCiyY2giOfuei32wCSt XY7M69zaBK5x8OUTHAtZ2226g2JLAHCm7Tb+8RXIxLmYM6boE19+tr41E4U7UNk/jTH0w0SocPjoYmBumSgIMtgcllXr7pjPIyjk3yIqE3hnAqmzc7bIeRFj nFZRk21NuxG+cHREwabEZqM0/fhYh0GDeBRwBKLimBD82BvvTweiFwA52SwJfI0S7UXCdNeEuQ4qfnvO/vA27lW+6CtgHuCavBBkS1QCOfH7YA== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org After reading the commit 640916db2bf7 ("can: c_can: Make it SMP safe") it may sound strange to see the IF_RX interface used by the can_inval_tx_object function. A comment was added to avoid any misunderstanding. Signed-off-by: Dario Binacchi --- Changes in v4: - Restore IF_RX interface. - Add a comment to clarify why IF_RX interface is used instead of IF_TX. drivers/net/can/c_can/c_can.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index dbcc1c1c92d6..6c6d0d0ff7b8 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -732,6 +732,12 @@ static void c_can_do_tx(struct net_device *dev) idx--; pend &= ~(1 << idx); obj = idx + C_CAN_MSG_OBJ_TX_FIRST; + + /* + * We use IF_RX interface instead of IF_TX because we are + * called from c_can_poll(), which runs inside NAPI. We are + * not trasmitting. + */ c_can_inval_tx_object(dev, IF_RX, obj); can_get_echo_skb(dev, idx, NULL); bytes += priv->dlc[idx]; From patchwork Tue Mar 2 21:54:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 393406 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D039CC2BA17 for ; Wed, 3 Mar 2021 04:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A23E364ECF for ; Wed, 3 Mar 2021 04:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1838595AbhCCEH1 (ORCPT ); Tue, 2 Mar 2021 23:07:27 -0500 Received: from smtp-17.italiaonline.it ([213.209.10.17]:52771 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2359539AbhCBWAu (ORCPT ); Tue, 2 Mar 2021 17:00:50 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id HCz0lBDmUlChfHCzBlGa0q; Tue, 02 Mar 2021 22:55:21 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614722121; bh=gGBb0if76oFz8ZwaKKCbLEQjDj90X/5zDbKBMeSdiUc=; h=From; b=T8B5ZefqPk3DmSIj78XmxkBIraj5oovEoTGNwI3NQdUftYczqjyYwtVeOPeO0WjdN VwEmR+E4viE9hJ+/PB3cjONepFPkrLiwZziq0ESRarJzX72x0/1TmMaAtLenEs83ZT Wzt67w6HL10O/lEaTI4YTXCCKaHYkCLHpWD9GYiZkO8X7yxBaXYELOz6dCBXJWjBQ1 SgMbyxHWD59HsSTkUFw94hwmjRkyXAgLM8zit3wzkAJfclg+c2J5yF0pzPX5LrwF/t FNffUmH3lWqs4Eftd3fymewl0OEd/5RR5ArHTwjVG++usdo889HwlQY9Gbi2gGAgnh I5LbG2BSsV8fA== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=603eb449 cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=YyHhdtpqV3cun0yf7GkA:9 From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Alexander Stein , Federico Vaga , Dario Binacchi , "David S. Miller" , Jakub Kicinski , Marc Kleine-Budde , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , YueHaibing , Zhang Qilong , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 4/6] can: c_can: use 32-bit write to set arbitration register Date: Tue, 2 Mar 2021 22:54:33 +0100 Message-Id: <20210302215435.18286-5-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210302215435.18286-1-dariobin@libero.it> References: <20210302215435.18286-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfALmbl+rhBfE4zafOS7jLa8Q+n7eEyC7LfLeVholBUrNRtsS4icLPd420gn24S1iGl7/F2v00nn0ztIvFSw3x2OYNtzQTD+NsS91Pkgzz4XXw7X7w5Kh Ld+nTL/fnRIOd2U6NtS717z6EmJmhr1XP2E5U0g2VjUil6TI4YchvC4rxhexKDqP7OXB870P9TvtyPnrZ0t58oNvdFkKJI0MjNTy8kqwluXWoM7wUTqMlEzf YzUul0/BzolOjdq+0a8bVBiRdpiDCU1xoPvuGmoC/OvRZLg9DnNrHPxrq2h5ed3wCW3mdzYT2eNzakA0L5sxAGCnRgljyNTMvfrMzmX0mf9MCrysHWZdxel3 QO6FtueafHelSduDqQCCly6SXty2mvxmyax2fZrk1LRWHw9zyhoM+bZr37K/LkLGWhHgNdvDKQTZfZrkbsOcH9fskjhZFee6dfHeYbtHYGKAcBKcFLDY/ac5 FeSnJPVy6air3fx2bIRbZKwtxmDb5d1/TXRKls0wMva5mkpKbG+Ou/cGkIBUxUBeqE+gm30oTIMIYPjU1gttCS2gUG1qa8jcpaYvc/MDP1p+ihVbLQHBgJ2n 5n9qaOGsri2Ub3j93+jY0nbyb1SFsnrlzIQyU0hT5fZrURLIMUwQNPVyNIscuxpQ/m3ZYN3lp7obxDu2o+UwrELXMQqJCfbm+FAiVX+H3tqdWQ== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The arbitration register is already set up with 32-bit writes in the other parts of the code except for this point. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/net/can/c_can/c_can.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index 6c6d0d0ff7b8..77b9aee56154 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -297,8 +297,7 @@ static void c_can_inval_msg_object(struct net_device *dev, int iface, int obj) { struct c_can_priv *priv = netdev_priv(dev); - priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), 0); - priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), 0); + priv->write_reg32(priv, C_CAN_IFACE(ARB1_REG, iface), 0); c_can_inval_tx_object(dev, iface, obj); } From patchwork Tue Mar 2 21:54:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 392563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEB45C2BA11 for ; Wed, 3 Mar 2021 04:23:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C65B064ECF for ; Wed, 3 Mar 2021 04:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1837702AbhCCEHQ (ORCPT ); Tue, 2 Mar 2021 23:07:16 -0500 Received: from smtp-17-i2.italiaonline.it ([213.209.12.17]:45236 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1574639AbhCBV5K (ORCPT ); Tue, 2 Mar 2021 16:57:10 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id HCz0lBDmUlChfHCzBlGa16; Tue, 02 Mar 2021 22:55:22 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614722122; bh=4b9PVZ3MxLkvS5A8CkTqZ5PcV+B4L4ylQmTKNgRUZvo=; h=From; b=w4Rd/dn4JUiSbY67+NLpIJzx8edb9u5IKZ9Z6i9lC4+PuPpWh0j+EfajQBQrlCeao Dv6dtMOVMe/uusFjCMbRK+MSjSy6hxJWHdZuiay64QN/QpBGcW5TtbN1G0weXhvt9W cpdr+kjbYSInV8YWHULizLCCYHikVAidnNhu4e5w839H+GZPlLIU6Qo6AGswDExyZN WAfaXDg+tH7BrHwwJt/d4HyhZH0x9r1lc9GYP2kMdfZaXWkYrZ0GfkQngGCPZlfZZJ TfZLecOY/0okDhb+mYYbbuSckyLrNgbOc+OgzK3qhjl58zNWzih2NwYu6QCebDqRv1 RjbyHzNCjm7xQ== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=603eb44a cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=QyXUC8HyAAAA:8 a=3axKsbaXVfasLmrsgWoA:9 a=_esk9xPdivsDxVPe:21 a=CIU-wB2mvstU2LXV:21 From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Alexander Stein , Federico Vaga , Dario Binacchi , "David S. Miller" , Jakub Kicinski , Marc Kleine-Budde , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , YueHaibing , Zhang Qilong , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 5/6] can: c_can: prepare to up the message objects number Date: Tue, 2 Mar 2021 22:54:34 +0100 Message-Id: <20210302215435.18286-6-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210302215435.18286-1-dariobin@libero.it> References: <20210302215435.18286-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfGkl4McvlMlllcR3UyCNT1nxEMU+GD3ecxFBo8K0nc9PC+sfdLnE2dvofZl8BybakUGYaz3iRxi/0QD1Eefucb+tTk32Ta6EsP2tH80r6AooSIZBMPVq w39mekN8TwuOZt01ACc6egFGyKsq8ITeu1cJT1bji3GIruk2zP7ioQXMP1KniobD4iWpNAFFdZ1MmwjXd/Z4Fw0pclZzomvXsM6et+6iuV4Bo5rDZMkr5Qob fZ8UJ8q9sz4/FGi7ovYzwJ4IKXqyotDPznJqdr9eXhQJgSFxYzTXYEbKrVQu0RXmDMTO+LcsPbr7KU+mpcBk3XpesZWQvh9NKDV/fJHa6ngGrnFs+Rm0uWsN 8mLk/qZhgDeuggKVQBUoYbSfuWd5u+t4AGjvnXa4od2UCqKYLniS4MVQBzjWjyL9P+xADAsWGMSU0WKnT+GHrEO4q0VjyBE70AL1sPolagDQlgmj1yI/GkCU CIFHdBI16TEDzLO4QC5kjx+SFN6ap/kszLhm1KTgFFqXU8FkUl6js+zb08NOasxGgYMPTanVLZPVGhTGXy9oM4LL+ZypGsN2dU8WzYSPrgBHCeSwtfudDxip h1G1qFoAaTmwOjCfqYoqRe9sXm2Bi4u4ZHm7P+aJARWJvr903b+clEEmQM+qDkHMjhggq/uE01WgWmsP7FjVccgyC9BPB7lvoiBJVeH4TME3vQ== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org As pointed by commit c0a9f4d396c9 ("can: c_can: Reduce register access") the "driver casts the 16 message objects in stone, which is completely braindead as contemporary hardware has up to 128 message objects". The patch prepares the module to extend the number of message objects beyond the 32 currently managed. This was achieved by transforming the constants used to manage RX/TX messages into variables without changing the driver policy. Signed-off-by: Dario Binacchi Reported-by: kernel test robot --- Changes in v4: - Use GENMASK() for setting msg_obj_rx_mask. Changes in v3: - Use unsigned int instead of int as type of the msg_obj_* fields in the c_can_priv structure. - Replace (u64)1 with 1UL in msg_obj_rx_mask setting. Changes in v2: - Fix compiling error reported by kernel test robot. - Add Reported-by tag. - Pass larger size to alloc_candev() routine to avoid an additional memory allocation/deallocation. drivers/net/can/c_can/c_can.c | 50 ++++++++++++++++---------- drivers/net/can/c_can/c_can.h | 23 ++++++------ drivers/net/can/c_can/c_can_pci.c | 2 +- drivers/net/can/c_can/c_can_platform.c | 2 +- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index 77b9aee56154..0052ba5197e0 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -173,9 +173,6 @@ /* Wait for ~1 sec for INIT bit */ #define INIT_WAIT_MS 1000 -/* napi related */ -#define C_CAN_NAPI_WEIGHT C_CAN_MSG_OBJ_RX_NUM - /* c_can lec values */ enum c_can_lec_type { LEC_NO_ERROR = 0, @@ -325,7 +322,7 @@ static void c_can_setup_tx_object(struct net_device *dev, int iface, * first, i.e. clear the MSGVAL flag in the arbiter. */ if (rtr != (bool)test_bit(idx, &priv->tx_dir)) { - u32 obj = idx + C_CAN_MSG_OBJ_TX_FIRST; + u32 obj = idx + priv->msg_obj_tx_first; c_can_inval_msg_object(dev, iface, obj); change_bit(idx, &priv->tx_dir); @@ -463,10 +460,10 @@ static netdev_tx_t c_can_start_xmit(struct sk_buff *skb, * prioritized. The lowest buffer number wins. */ idx = fls(atomic_read(&priv->tx_active)); - obj = idx + C_CAN_MSG_OBJ_TX_FIRST; + obj = idx + priv->msg_obj_tx_first; /* If this is the last buffer, stop the xmit queue */ - if (idx == C_CAN_MSG_OBJ_TX_NUM - 1) + if (idx == priv->msg_obj_tx_num - 1) netif_stop_queue(dev); /* * Store the message in the interface so we can call @@ -549,17 +546,18 @@ static int c_can_set_bittiming(struct net_device *dev) */ static void c_can_configure_msg_objects(struct net_device *dev) { + struct c_can_priv *priv = netdev_priv(dev); int i; /* first invalidate all message objects */ - for (i = C_CAN_MSG_OBJ_RX_FIRST; i <= C_CAN_NO_OF_OBJECTS; i++) + for (i = priv->msg_obj_rx_first; i <= priv->msg_obj_num; i++) c_can_inval_msg_object(dev, IF_RX, i); /* setup receive message objects */ - for (i = C_CAN_MSG_OBJ_RX_FIRST; i < C_CAN_MSG_OBJ_RX_LAST; i++) + for (i = priv->msg_obj_rx_first; i < priv->msg_obj_rx_last; i++) c_can_setup_receive_object(dev, IF_RX, i, 0, 0, IF_MCONT_RCV); - c_can_setup_receive_object(dev, IF_RX, C_CAN_MSG_OBJ_RX_LAST, 0, 0, + c_can_setup_receive_object(dev, IF_RX, priv->msg_obj_rx_last, 0, 0, IF_MCONT_RCV_EOB); } @@ -730,7 +728,7 @@ static void c_can_do_tx(struct net_device *dev) while ((idx = ffs(pend))) { idx--; pend &= ~(1 << idx); - obj = idx + C_CAN_MSG_OBJ_TX_FIRST; + obj = idx + priv->msg_obj_tx_first; /* * We use IF_RX interface instead of IF_TX because we are @@ -746,7 +744,7 @@ static void c_can_do_tx(struct net_device *dev) /* Clear the bits in the tx_active mask */ atomic_sub(clr, &priv->tx_active); - if (clr & (1 << (C_CAN_MSG_OBJ_TX_NUM - 1))) + if (clr & (1 << (priv->msg_obj_tx_num - 1))) netif_wake_queue(dev); if (pkts) { @@ -761,11 +759,11 @@ static void c_can_do_tx(struct net_device *dev) * raced with the hardware or failed to readout all upper * objects in the last run due to quota limit. */ -static u32 c_can_adjust_pending(u32 pend) +static u32 c_can_adjust_pending(u32 pend, u32 rx_mask) { u32 weight, lasts; - if (pend == RECEIVE_OBJECT_BITS) + if (pend == rx_mask) return pend; /* @@ -868,8 +866,7 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota) * It is faster to read only one 16bit register. This is only possible * for a maximum number of 16 objects. */ - BUILD_BUG_ON_MSG(C_CAN_MSG_OBJ_RX_LAST > 16, - "Implementation does not support more message objects than 16"); + WARN_ON(priv->msg_obj_rx_last > 16); while (quota > 0) { if (!pend) { @@ -880,7 +877,8 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota) * If the pending field has a gap, handle the * bits above the gap first. */ - toread = c_can_adjust_pending(pend); + toread = c_can_adjust_pending(pend, + priv->msg_obj_rx_mask); } else { toread = pend; } @@ -1211,17 +1209,31 @@ static int c_can_close(struct net_device *dev) return 0; } -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 = msg_obj_num / 2; - dev = alloc_candev(sizeof(struct c_can_priv), C_CAN_MSG_OBJ_TX_NUM); + dev = alloc_candev(sizeof(*priv) + sizeof(u32) * msg_obj_tx_num, + msg_obj_tx_num); if (!dev) return NULL; priv = netdev_priv(dev); - netif_napi_add(dev, &priv->napi, c_can_poll, C_CAN_NAPI_WEIGHT); + priv->msg_obj_num = msg_obj_num; + priv->msg_obj_rx_num = msg_obj_num - msg_obj_tx_num; + priv->msg_obj_rx_first = 1; + priv->msg_obj_rx_last = + priv->msg_obj_rx_first + priv->msg_obj_rx_num - 1; + priv->msg_obj_rx_mask = GENMASK(priv->msg_obj_rx_num - 1, 0); + + priv->msg_obj_tx_num = msg_obj_tx_num; + priv->msg_obj_tx_first = priv->msg_obj_rx_last + 1; + priv->msg_obj_tx_last = + priv->msg_obj_tx_first + priv->msg_obj_tx_num - 1; + + netif_napi_add(dev, &priv->napi, c_can_poll, priv->msg_obj_rx_num); priv->dev = dev; priv->can.bittiming_const = &c_can_bittiming_const; diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h index 90d3d2e7a086..68295fab83d9 100644 --- a/drivers/net/can/c_can/c_can.h +++ b/drivers/net/can/c_can/c_can.h @@ -22,18 +22,7 @@ #ifndef C_CAN_H #define C_CAN_H -/* message object split */ #define C_CAN_NO_OF_OBJECTS 32 -#define C_CAN_MSG_OBJ_RX_NUM 16 -#define C_CAN_MSG_OBJ_TX_NUM 16 - -#define C_CAN_MSG_OBJ_RX_FIRST 1 -#define C_CAN_MSG_OBJ_RX_LAST (C_CAN_MSG_OBJ_RX_FIRST + \ - C_CAN_MSG_OBJ_RX_NUM - 1) - -#define C_CAN_MSG_OBJ_TX_FIRST (C_CAN_MSG_OBJ_RX_LAST + 1) - -#define RECEIVE_OBJECT_BITS 0x0000ffff enum reg { C_CAN_CTRL_REG = 0, @@ -193,6 +182,14 @@ struct c_can_priv { struct napi_struct napi; struct net_device *dev; struct device *device; + unsigned int msg_obj_num; + unsigned int msg_obj_rx_num; + unsigned int msg_obj_tx_num; + unsigned int msg_obj_rx_first; + unsigned int msg_obj_rx_last; + unsigned int msg_obj_tx_first; + unsigned int msg_obj_tx_last; + u32 msg_obj_rx_mask; atomic_t tx_active; atomic_t sie_pending; unsigned long tx_dir; @@ -209,10 +206,10 @@ struct c_can_priv { void (*raminit) (const struct c_can_priv *priv, bool enable); u32 comm_rcv_high; u32 rxmasked; - u32 dlc[C_CAN_MSG_OBJ_TX_NUM]; + u32 dlc[]; }; -struct net_device *alloc_c_can_dev(void); +struct net_device *alloc_c_can_dev(int msg_obj_num); void free_c_can_dev(struct net_device *dev); int register_c_can_dev(struct net_device *dev); void unregister_c_can_dev(struct net_device *dev); diff --git a/drivers/net/can/c_can/c_can_pci.c b/drivers/net/can/c_can/c_can_pci.c index 406b4847e5dc..3752f68d095e 100644 --- a/drivers/net/can/c_can/c_can_pci.c +++ b/drivers/net/can/c_can/c_can_pci.c @@ -149,7 +149,7 @@ static int c_can_pci_probe(struct pci_dev *pdev, } /* allocate the c_can device */ - dev = alloc_c_can_dev(); + dev = alloc_c_can_dev(C_CAN_NO_OF_OBJECTS); if (!dev) { ret = -ENOMEM; goto out_iounmap; diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index 05f425ceb53a..a5b9b1a93702 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c @@ -293,7 +293,7 @@ static int c_can_plat_probe(struct platform_device *pdev) } /* allocate the c_can device */ - dev = alloc_c_can_dev(); + dev = alloc_c_can_dev(C_CAN_NO_OF_OBJECTS); if (!dev) { ret = -ENOMEM; goto exit; From patchwork Tue Mar 2 21:54:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 392562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF170C2BA12 for ; Wed, 3 Mar 2021 04:23:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B95264E87 for ; Wed, 3 Mar 2021 04:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1837113AbhCCEHA (ORCPT ); Tue, 2 Mar 2021 23:07:00 -0500 Received: from smtp-17-i2.italiaonline.it ([213.209.12.17]:48667 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1574696AbhCBV5C (ORCPT ); Tue, 2 Mar 2021 16:57:02 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id HCz0lBDmUlChfHCzClGa1g; Tue, 02 Mar 2021 22:55:22 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614722122; bh=96bNPE5p77n9NSTEC2vRJMppfBiDkxxfSZBnZPG23Z4=; h=From; b=WGB6AL5sNFQUalhyIF+c6GjH5OZjw19SU/mWs5UnXMSvY1xhWm+7YnAdRicbhs9it /yadILZRker8RukHks7ZXg4eSlWjL8BEzlDl2TnwPW3r8UW8Bj7UKMIqWPT8zKq8eQ 7pqnyUCfpshxFGWivCXdzfo44NU/Uu9lm4RIZu1OBdZ95tFmnFtvdixr/u9+tS6pBL S00MIf+YzmdkX/CG4LFnzb5XpAe3yEy9WU4bInsA6GMNVztKS3hCaFcAkmlWoX4aPA iP50Nlmj7t3S10gZGcpBh5DGHUmmK3nrabPv+/reLtQHubq81QKj2ii9JLgn+mQSBM 6n5OVa4Wq4rvQ== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=603eb44a cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=tUZDV6Rw8AmhtNJeqpIA:9 a=LQ2ymOy1cPXeYbwl:21 a=OSFjYBiQSmxbRpmb:21 From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Alexander Stein , Federico Vaga , Dario Binacchi , "David S. Miller" , Jakub Kicinski , Marc Kleine-Budde , Oliver Hartkopp , Vincent Mailhol , Wolfgang Grandegger , YueHaibing , Zhang Qilong , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 6/6] can: c_can: add support to 64 message objects Date: Tue, 2 Mar 2021 22:54:35 +0100 Message-Id: <20210302215435.18286-7-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210302215435.18286-1-dariobin@libero.it> References: <20210302215435.18286-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfGkl4McvlMlllcR3UyCNT1nxEMU+GD3ecxFBo8K0nc9PC+sfdLnE2dvofZl8BybakUGYaz3iRxi/0QD1Eefucb+tTk32Ta6EsP2tH80r6AooSIZBMPVq w39mekN8TwuOZt01ACc6egFGyKsq8ITeu1cJT1bji3GIruk2zP7ioQXMP1KniobD4iWpNAFFdZ1MmwjXd/Z4Fw0pclZzomvXsM6et+6iuV4Bo5rDZMkr5Qob fZ8UJ8q9sz4/FGi7ovYzwJ4IKXqyotDPznJqdr9eXhQJgSFxYzTXYEbKrVQu0RXmDMTO+LcsPbr7KU+mpcBk3XpesZWQvh9NKDV/fJHa6ngGrnFs+Rm0uWsN 8mLk/qZhgDeuggKVQBUoYbSfuWd5u+t4AGjvnXa4od2UCqKYLniS4MVQBzjWjyL9P+xADAsWGMSU0WKnT+GHrEO4q0VjyBE70AL1sPolagDQlgmj1yI/GkCU CIFHdBI16TEDzLO4QC5kjx+SFN6ap/kszLhm1KTgFFqXU8FkUl6js+zb08NOasxGgYMPTanVLZPVGhTGXy9oM4LL+ZypGsN2dU8WzYSPrgBHCeSwtfudDxip h1G1qFoAaTmwOjCfqYoqRe9sXm2Bi4u4ZHm7P+aJARWJvr903b+clEEmQM+qDkHMjhggq/uE01WgWmsP7FjVccgyC9BPB7lvoiBJVeH4TME3vQ== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org D_CAN controller supports 16, 32, 64 or 128 message objects, comparing to 32 on C_CAN. AM335x/AM437x Sitara processors and DRA7 SOC all instantiate a D_CAN controller with 64 message objects, as described in the "DCAN features" subsection of the CAN chapter of their technical reference manuals. The driver policy has been kept unchanged, and as in the previous version, the first half of the message objects is used for reception and the second for transmission. The I/O load is increased only in the case of 64 message objects, keeping it unchanged in the case of 32. Two 32-bit read accesses are in fact required, which however remained at 16-bit for configurations with 32 message objects. Signed-off-by: Dario Binacchi --- Changes in v4: - Use BIT() for setting single bits and GENMASK() for setting masks. Changes in v3: - Use unsigned int instead of int as type of the msg_obj_num field in c_can_driver_data and c_can_pci_data structures. Changes in v2: - Add message objects number to PCI driver data. drivers/net/can/c_can/c_can.c | 30 +++++++++++++++----------- drivers/net/can/c_can/c_can.h | 5 +++-- drivers/net/can/c_can/c_can_pci.c | 6 +++++- drivers/net/can/c_can/c_can_platform.c | 6 +++++- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index 0052ba5197e0..41e4ec6ab0aa 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -475,7 +475,7 @@ static netdev_tx_t c_can_start_xmit(struct sk_buff *skb, can_put_echo_skb(skb, dev, idx, 0); /* Update the active bits */ - atomic_add((1 << idx), &priv->tx_active); + atomic_add(BIT(idx), &priv->tx_active); /* Start transmission */ c_can_object_put(dev, IF_TX, obj, IF_COMM_TX); @@ -723,11 +723,15 @@ static void c_can_do_tx(struct net_device *dev) struct net_device_stats *stats = &dev->stats; u32 idx, obj, pkts = 0, bytes = 0, pend, clr; - clr = pend = priv->read_reg(priv, C_CAN_INTPND2_REG); + if (priv->msg_obj_tx_last > 32) + pend = priv->read_reg32(priv, C_CAN_INTPND3_REG); + else + pend = priv->read_reg(priv, C_CAN_INTPND2_REG); + clr = pend; while ((idx = ffs(pend))) { idx--; - pend &= ~(1 << idx); + pend &= ~BIT(idx); obj = idx + priv->msg_obj_tx_first; /* @@ -744,7 +748,7 @@ static void c_can_do_tx(struct net_device *dev) /* Clear the bits in the tx_active mask */ atomic_sub(clr, &priv->tx_active); - if (clr & (1 << (priv->msg_obj_tx_num - 1))) + if (clr & BIT(priv->msg_obj_tx_num - 1)) netif_wake_queue(dev); if (pkts) { @@ -781,9 +785,10 @@ static u32 c_can_adjust_pending(u32 pend, u32 rx_mask) * Find the first set bit after the gap. We walk backwards * from the last set bit. */ - for (lasts--; pend & (1 << (lasts - 1)); lasts--); + for (lasts--; pend & BIT(lasts - 1); lasts--) + ; - return pend & ~((1 << lasts) - 1); + return pend & ~GENMASK(lasts - 1, 0); } static inline void c_can_rx_object_get(struct net_device *dev, @@ -840,7 +845,12 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv, static inline u32 c_can_get_pending(struct c_can_priv *priv) { - u32 pend = priv->read_reg(priv, C_CAN_NEWDAT1_REG); + u32 pend; + + if (priv->msg_obj_rx_last > 16) + pend = priv->read_reg32(priv, C_CAN_NEWDAT1_REG); + else + pend = priv->read_reg(priv, C_CAN_NEWDAT1_REG); return pend; } @@ -862,12 +872,6 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota) struct c_can_priv *priv = netdev_priv(dev); u32 pkts = 0, pend = 0, toread, n; - /* - * It is faster to read only one 16bit register. This is only possible - * for a maximum number of 16 objects. - */ - WARN_ON(priv->msg_obj_rx_last > 16); - while (quota > 0) { if (!pend) { pend = c_can_get_pending(priv); diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h index 68295fab83d9..bd291e998a51 100644 --- a/drivers/net/can/c_can/c_can.h +++ b/drivers/net/can/c_can/c_can.h @@ -22,8 +22,6 @@ #ifndef C_CAN_H #define C_CAN_H -#define C_CAN_NO_OF_OBJECTS 32 - enum reg { C_CAN_CTRL_REG = 0, C_CAN_CTRL_EX_REG, @@ -61,6 +59,7 @@ enum reg { C_CAN_NEWDAT2_REG, C_CAN_INTPND1_REG, C_CAN_INTPND2_REG, + C_CAN_INTPND3_REG, C_CAN_MSGVAL1_REG, C_CAN_MSGVAL2_REG, C_CAN_FUNCTION_REG, @@ -122,6 +121,7 @@ static const u16 __maybe_unused reg_map_d_can[] = { [C_CAN_NEWDAT2_REG] = 0x9E, [C_CAN_INTPND1_REG] = 0xB0, [C_CAN_INTPND2_REG] = 0xB2, + [C_CAN_INTPND3_REG] = 0xB4, [C_CAN_MSGVAL1_REG] = 0xC4, [C_CAN_MSGVAL2_REG] = 0xC6, [C_CAN_IF1_COMREQ_REG] = 0x100, @@ -161,6 +161,7 @@ struct raminit_bits { struct c_can_driver_data { enum c_can_dev_id id; + unsigned int msg_obj_num; /* RAMINIT register description. Optional. */ const struct raminit_bits *raminit_bits; /* Array of START/DONE bit positions */ diff --git a/drivers/net/can/c_can/c_can_pci.c b/drivers/net/can/c_can/c_can_pci.c index 3752f68d095e..9415b12d26c8 100644 --- a/drivers/net/can/c_can/c_can_pci.c +++ b/drivers/net/can/c_can/c_can_pci.c @@ -31,6 +31,8 @@ enum c_can_pci_reg_align { struct c_can_pci_data { /* Specify if is C_CAN or D_CAN */ enum c_can_dev_id type; + /* Number of message objects */ + unsigned int msg_obj_num; /* Set the register alignment in the memory */ enum c_can_pci_reg_align reg_align; /* Set the frequency */ @@ -149,7 +151,7 @@ static int c_can_pci_probe(struct pci_dev *pdev, } /* allocate the c_can device */ - dev = alloc_c_can_dev(C_CAN_NO_OF_OBJECTS); + dev = alloc_c_can_dev(c_can_pci_data->msg_obj_num); if (!dev) { ret = -ENOMEM; goto out_iounmap; @@ -253,6 +255,7 @@ static void c_can_pci_remove(struct pci_dev *pdev) static const struct c_can_pci_data c_can_sta2x11= { .type = BOSCH_C_CAN, + .msg_obj_num = 32, .reg_align = C_CAN_REG_ALIGN_32, .freq = 52000000, /* 52 Mhz */ .bar = 0, @@ -260,6 +263,7 @@ static const struct c_can_pci_data c_can_sta2x11= { static const struct c_can_pci_data c_can_pch = { .type = BOSCH_C_CAN, + .msg_obj_num = 32, .reg_align = C_CAN_REG_32, .freq = 50000000, /* 50 MHz */ .init = c_can_pci_reset_pch, diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index a5b9b1a93702..87a145b67a2f 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c @@ -192,10 +192,12 @@ static void c_can_hw_raminit(const struct c_can_priv *priv, bool enable) static const struct c_can_driver_data c_can_drvdata = { .id = BOSCH_C_CAN, + .msg_obj_num = 32, }; static const struct c_can_driver_data d_can_drvdata = { .id = BOSCH_D_CAN, + .msg_obj_num = 32, }; static const struct raminit_bits dra7_raminit_bits[] = { @@ -205,6 +207,7 @@ static const struct raminit_bits dra7_raminit_bits[] = { static const struct c_can_driver_data dra7_dcan_drvdata = { .id = BOSCH_D_CAN, + .msg_obj_num = 64, .raminit_num = ARRAY_SIZE(dra7_raminit_bits), .raminit_bits = dra7_raminit_bits, .raminit_pulse = true, @@ -217,6 +220,7 @@ static const struct raminit_bits am3352_raminit_bits[] = { static const struct c_can_driver_data am3352_dcan_drvdata = { .id = BOSCH_D_CAN, + .msg_obj_num = 64, .raminit_num = ARRAY_SIZE(am3352_raminit_bits), .raminit_bits = am3352_raminit_bits, }; @@ -293,7 +297,7 @@ static int c_can_plat_probe(struct platform_device *pdev) } /* allocate the c_can device */ - dev = alloc_c_can_dev(C_CAN_NO_OF_OBJECTS); + dev = alloc_c_can_dev(drvdata->msg_obj_num); if (!dev) { ret = -ENOMEM; goto exit;