From patchwork Thu Feb 25 21:51:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 12105065 X-Patchwork-Delegate: kuba@kernel.org 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=ham 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 BF1F0C433DB for ; Thu, 25 Feb 2021 21:54:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8334564F30 for ; Thu, 25 Feb 2021 21:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234814AbhBYVyH (ORCPT ); Thu, 25 Feb 2021 16:54:07 -0500 Received: from smtp-17.italiaonline.it ([213.209.10.17]:50917 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234637AbhBYVxM (ORCPT ); Thu, 25 Feb 2021 16:53:12 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id FOYQlNUJ2lChfFOYVlkbfa; Thu, 25 Feb 2021 22:52:20 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614289940; bh=qdqprpCrTgqGjjL1MPD2Trs9CbuR4PMIgLdSlLVKd3w=; h=From; b=eyAg1IRpgtVyo7sJUr3p+9ngUEWuCS3gwC/fZpmeoufaE/puapXNcPyW6JNRarF0F ShBtIIdIPjq9gvKpO0juaHOPA+c45GuRhpPfKGAYTSX0M+jCxxH0GoRHCEp28oiQcF FSDCII34hgh4nT/l4LVvsTDBszClrFdL4ZpiT7AFdCqIk7P1qU549wxjjfr9BbsoOQ ev06CF7C6j2xG8ioNvQHAdv2UTcSsF+QVPMd6VyyCJIXFvNda3qdllRxVSMqpYs4mL imfJj4gKQNauYAIMjs3yGZduh0OXbBE4AM165bSaAsO+3zbff8LddFec3Dyowh4bXo zW5YCDke/sqSQ== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=60381c14 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 v2 1/6] can: c_can: remove unused code Date: Thu, 25 Feb 2021 22:51:50 +0100 Message-Id: <20210225215155.30509-2-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210225215155.30509-1-dariobin@libero.it> References: <20210225215155.30509-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfEG9PQ+25SLWZPHaldFNnMkDX4Sw1bijmupDMTfL6BZREdLUv4+k53du8bwQYXjZGuTGQNGs3OF5C1J92zxj3qI2ltmGoYfUV7oVMoQAApiBwRRNL+Pr gVzciCumKYfVt5inQfFEyyCLWHsx+mU9rjz5AXpQw3BphT7CTBWgjzsA0PWB8NURqY5Vf7duDIk9mGScuspB9iHLVE+dU7RH7pUoZni5JxDCh+04utbBTdez G41OCGNUwDcDaycXkH17HIEIDAMbZuD36Do+qYoWpCO5SRsSoAfX9iJc7VdkCyBXAiOoQOcYi8dYng8aHf9vLBt/EKPNT0PNIsobUZGSonOUYZQ+fDUwjZnM b6AvdkO46u+GlCTGsgzD57lAihDCLq9T7re3ppMfVPEaJAcZ4I4LMdQh6ID5yZDVgyJO+eTwR6l6qdTGfx69Nkkyh8KZ7bslIAT+6H6guAoMlRXd3H7pK2OO Yy/+cynNKuXE1NlNBc0nAQnEhFeJqLgxT/Jlie5u/eiYxOPx/MqerqSPJCBSJm7DMKSoq1f/W1s51YcjzdYTl776glG6ehJO+6cMG+WSJAoznp5Hm+raNYJY vRIGbY89kM/dI24K+cOPudt6AV+iRLAyE/5L4uJiwP1Z8kSTGbfI6LsKiR5RK0HzlGs92dAmI67CE8yFCT7ctJaTm5hLBolwycbU9Pp6obLCkw== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Thu Feb 25 21:51:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 12105083 X-Patchwork-Delegate: kuba@kernel.org 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 0705BC433E0 for ; Thu, 25 Feb 2021 21:57:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3E5264EBA for ; Thu, 25 Feb 2021 21:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234687AbhBYV5C (ORCPT ); Thu, 25 Feb 2021 16:57:02 -0500 Received: from smtp-17-i2.italiaonline.it ([213.209.12.17]:41073 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234875AbhBYVzT (ORCPT ); Thu, 25 Feb 2021 16:55:19 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id FOYQlNUJ2lChfFOYWlkbfx; Thu, 25 Feb 2021 22:52:21 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614289941; bh=ZwZwTipdZKxY6qGd4VuGRlxL2+9rpHSGnSFdq6NXms8=; h=From; b=nPqtD7JEACtSZgRq+Y+7+amJ9UEw2g4F9Ow0l6RJbzEibTAkGaa7bF2WhTVHlxve1 oHLwSmqke9ZWsWeNFcZGlx7TMv4clil4jCCdM2x2yYk4PPqLqVfF2Q31n89XWG/tr6 CJODTsADPWI3Qj7pib1oLuWXv4TABf7i96VTYEo2z4eK+UDEFmz00wDFn/6rrvnRY+ Lyzb1yl/M9JnrVNmFWsMJ8wpYLTEwVZjBPVt97wEgQA7eh34VJ1j63H4uX08SbP6FB wZPg1Bq2VrQk6m2qfdl/TKioRQND4v7VMJuZPB4j76gknFcgbnSrW4CjJfrX5h2J1T LUv71dyyg42HA== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=60381c15 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 v2 2/6] can: c_can: fix indentation Date: Thu, 25 Feb 2021 22:51:51 +0100 Message-Id: <20210225215155.30509-3-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210225215155.30509-1-dariobin@libero.it> References: <20210225215155.30509-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfLyEMjqPMWD6UklMARrB4DSdHDnqxkwrej79EXjWITQpcm3rEgvUMPyPzGMGZPXL/kNJ2iArJDBnhfYbLPSejaI69YZVumO8EuiQyLE4G976ejrsS8FX grbzC2RPpJG+jl9ysT98tvGC6yM10VDgeskEII7SoPXfswWqhs2FOsB9AtAj5B5arznhapM0MCs0k5AFr+cr9868DHBba+gY4brGgRirOzQgdNvUBBJxFqyM mLRgTzswhkuBukt/9pDXwM3A2qZ8IIajyFDKW9aIo1j1j2p+UUQPNBrNEypdkY/fHOamth4l2O/MmQDolGW/QoFGPfzeKIcZrKBYogn6sI44pcbOHCp6thMt Y5xoY8Xw7NSqyhtL/KDG4hzzOSjm4ibSUY7Qxe56qaX74l5F34V0PxC3w+gxNHCRWKY4Xxg1qptR+nnoC4pdZQeM9O5IjX/xMj8RApBZ4EiVO4R3G0tRsnko k9CNEsBRDql69PX45vBm9/DHYTb3pqo1g6Y/787aW0Ce7/eX3HMKkglTy4eD5qgWKy6eTBcv3Tu2xcPiRaeKi3f4qZu3fFizD/3R1bHj0Xgz/sccSSvSWjic UBgK5sPz7+0D8zoTZZk5UcKYj4dPF9lQroIJtwBjbvnzb0MeCr3X1NKQVZvzDtFHsdXeAJmV7NrSK65/oVfTAklmpJfDFueUkiQeDqTkAk5Cdw== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Thu Feb 25 21:51:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 12105085 X-Patchwork-Delegate: kuba@kernel.org 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 546F0C433DB for ; Thu, 25 Feb 2021 21:58:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16FEA614A7 for ; Thu, 25 Feb 2021 21:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234548AbhBYV5q (ORCPT ); Thu, 25 Feb 2021 16:57:46 -0500 Received: from smtp-17-i2.italiaonline.it ([213.209.12.17]:57611 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234900AbhBYVzl (ORCPT ); Thu, 25 Feb 2021 16:55:41 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id FOYQlNUJ2lChfFOYXlkbgJ; Thu, 25 Feb 2021 22:52:22 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614289942; bh=j7GRCoTejXM7B9fJVl1bTmRrEzrTT3KamKBLcuWoSdk=; h=From; b=aQXhC9sBNN93GeYw4esKYoNGJMPZMNLWgrYE83abP0Nw/CGXJoyoPv+KAzAnF5E/l QvzHd+pKIbGa5AvOD3OyDMhHTCw8Rvr5nzCK+GvkJCyAxH0CfjXBJ6ePScVG/lOzRA +zidJq7s9Vq/B9LusPURVs7elE+g/X3RRzCaDQB4g/Awe4Uq23D7bf64xwJs+zV2tb 3XsrkAN/+r1CijnWd1r4OQ9ByTRFxqaAOcAEDNN5K2hZoGVRKzuXL799Ea4wnu0CCG FOBnyXHLLYjfZN8dsqk5DQJzxKDKcXJvwl7OdBFm4UEpfkp67a6+0axJRdpCSe0kTh MU32eX7SV0vuQ== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=60381c16 cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=6WxvSi62EpDuW4hn7DoA: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 v2 3/6] can: c_can: fix control interface used by c_can_do_tx Date: Thu, 25 Feb 2021 22:51:52 +0100 Message-Id: <20210225215155.30509-4-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210225215155.30509-1-dariobin@libero.it> References: <20210225215155.30509-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfPTJVu/b4W/lDf0Rt18zHhRwMpHd1BkDGPYy0FpY80gMrR9Lu9WZompAs77KBBfKMdwZRlBBH0dvhFQeVLFKK3CGvAcOJ9BD+RkDPijbzbJ3Z27HSyBc wOItyxSDdpNDePV3OQmXEkG8mE+tGXsQF8jRD4tyIDGWGWu38s5QBQSmCDxTGITHVYuagr0DE6ux1lOJmBJLkiKh/+KzCfJ4EasyY0JTKmaBasKwIzQW8Qbs zDmkMzh4RpdZ3+LQ7eD2HvBgJaW52frQ/+d4jYvj+EAkgYOg61k/oPt65aqOjlBY2p+ZLpQ0xcu6e7OyYI/vrSHv2iElTTs5XgFDYkrqMyuKfJ0YNpnOAqKI uLEv/KOtms3BQNVwz8jXT+O5EcO57ZEj1kx3URL0OnNPHZnSLJzlPy5GOVQ4cv6hdTM7qX8LeomhWpfTVUg2+F7oBIXeUkYxwsF+Gm8iOm/93z9s22z2TVGZ 9ycaHOc35NAnPDFgttLcf/FWbfYOIhR15SNPqlHsaxAE+bIUd3JgDVQU156m8nM/LkduMCAvsqhPEpbuBNsWqi2kKlTKkkSYze6oiIlhwcSWmHwVnFd3/zhX /8fLDv61eFQezQaSTPPE8ok9UUayGvdQIpwM8phZkaTEvGtXYtlnfY2xiM2iMSusGT3X7yelQqEURw3j1XJQXGkpU7knR/CsxnNTsKrOwQP1eQ== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org According to commit 640916db2bf7 ("can: c_can: Make it SMP safe") let RX use IF1 (i.e. IF_RX) and TX use IF2 (i.e. IF_TX). 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 dbcc1c1c92d6..69526c3a671c 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -732,7 +732,7 @@ static void c_can_do_tx(struct net_device *dev) idx--; pend &= ~(1 << idx); obj = idx + C_CAN_MSG_OBJ_TX_FIRST; - c_can_inval_tx_object(dev, IF_RX, obj); + c_can_inval_tx_object(dev, IF_TX, obj); can_get_echo_skb(dev, idx, NULL); bytes += priv->dlc[idx]; pkts++; From patchwork Thu Feb 25 21:51:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 12105087 X-Patchwork-Delegate: kuba@kernel.org 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=ham 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 9502AC433E9 for ; Thu, 25 Feb 2021 21:58:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5751764EBA for ; Thu, 25 Feb 2021 21:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234460AbhBYV6j (ORCPT ); Thu, 25 Feb 2021 16:58:39 -0500 Received: from smtp-17-i2.italiaonline.it ([213.209.12.17]:33832 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234840AbhBYV5g (ORCPT ); Thu, 25 Feb 2021 16:57:36 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id FOYQlNUJ2lChfFOYYlkbgi; Thu, 25 Feb 2021 22:52:22 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614289943; bh=BCMzyFPGjvLZKNUS2sizrsXN5C/G8I7qiN9C3GvALOQ=; h=From; b=G/sqbnbhoBrcJVq4yhhyZ1gRfCNRus6HLixJb3gvcg+gdfpPzgd5whGJLColg977R 60z3nofAlamkDuTthuedA2r3ngmYH6sx8R9uPzzQdn3gjl7SC4VEtogzcc5QEVgbGM 7jeMlyzif3LpyaZ8aFMTuZe+07D5WlByeDV6SJN3/t2BqsrlA4vh+cWQVg63KCzVSM Ce4doVJeeEBLkgFB0KhcguInW0xHITeKXi106NVTBoG4rZmMBN+xh4skXjUJ4HEAng 8rMTBvXxyiYoqh+sNNTK2899ZSWKGdPqfeqyDyO8jXZRibZvhKE94wtGu9FH1MlyWA 7iQzwU/MRZU4g== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=60381c17 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 v2 4/6] can: c_can: use 32-bit write to set arbitration register Date: Thu, 25 Feb 2021 22:51:53 +0100 Message-Id: <20210225215155.30509-5-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210225215155.30509-1-dariobin@libero.it> References: <20210225215155.30509-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfN5b3Rqft8U7sYPJxUkdMUWC1LS8OtnTPA11KZdrUvwXZNfnsJYRZ+Vn1uNUlhHDizOz33lXjueok4cZYUrttT9Of6L/P+Tc2dGCGoMKxQQs8KeSBVNo KtBLeHv0L07u/tTEJao2Ybhh4h/HrROJe/uHI3wOI8wwhIF9FSJCR9hgWWNJAtUzDYCwJWpVZPXit6HjCQOVeB0eo0BjmghmLlZOjLZPuK7+6Cg4rIDZIvCC 66o1nWgRniRAB8bjRte8XAxfZlxz8VtKCWDBverXiPHJmT57HaoZXGqUPDb4dZP8pufWDWCKWxdC9g2kF9XZU44SEzytO5YXEOzklNzuetTB57xyr5xlX/e0 Qi5W0claOPGkj+gpYTFmL3d36ZCQzR+C/U+pk2eNa0D53ZPiphE8MbFmgwTlfgCeuADde47OEwf+E8SddSKXeLFN9xhYmsu88aZehVdgu+g36I6NPDfA+RXB eDavfma1gpo6Vw/7NkzILVDeSq/GkSe5UQGvTlkhzhtGyp0+Y0GkZuEVSCE83lzB+NJLHfRMsZhofZe5qg6rfaIMuXpvJhl8FtSEQ7ffmCnGB0jDWBrkaTs2 smhF7ZLVjFugHl7vQ9rhfodC41wttg2vza7XzPP2RJcHa2qLtamUv3W7jzPVULpTK1o91l/DmcN48RD5epR8j8h8kUjVmTK0tRw/C0kWLn8bLA== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 69526c3a671c..7081cfaf62e2 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 Thu Feb 25 21:51:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 12105067 X-Patchwork-Delegate: kuba@kernel.org 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 0EA11C433E9 for ; Thu, 25 Feb 2021 21:54:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C50EF64F30 for ; Thu, 25 Feb 2021 21:54:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234764AbhBYVyl (ORCPT ); Thu, 25 Feb 2021 16:54:41 -0500 Received: from smtp-17-i2.italiaonline.it ([213.209.12.17]:41073 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234690AbhBYVx7 (ORCPT ); Thu, 25 Feb 2021 16:53:59 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id FOYQlNUJ2lChfFOYZlkbh5; Thu, 25 Feb 2021 22:52:23 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614289943; bh=zy/Yf3Kgo4Te1FRxHWA15U6o/XGqbq1XQzSP9bdfciE=; h=From; b=iDOVa119YGJQNDmTGDvnaPnU2Zg4QpMU/EQTEMSNz8R9ae/t/dni3c+5nH9C+k4jF lNuISNW0Z1mZO+9i1od/KH2DD/4ZFoKJsGavwUrNYS5TJZf/ik6DjXBmrxUc12xQhA buVK3NTDU73XSHePB22NWKZIaGkDLGkbOQ3hPUynmY1regxPBpW4nKjXfBkYiUmrFC p6sSQQFKZcR3d5v+4fgkRSi1I8FTYrffmD7iX7jJ6fwyT3x+c5FLNt1wS4WpmzNKkd fVnzH9DeAD1Yo2MGNts5XXwZFgTL+twSHaYmPq/drW5NHu1uYxgGox1ADfTVbFnzRr 4UFcoRRnm9V5g== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=60381c17 cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=QyXUC8HyAAAA:8 a=3axKsbaXVfasLmrsgWoA:9 a=i3JErd2s4V1dzG0V:21 a=NL_c-FhuMFmCrXwt: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 v2 5/6] can: c_can: prepare to up the message objects number Date: Thu, 25 Feb 2021 22:51:54 +0100 Message-Id: <20210225215155.30509-6-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210225215155.30509-1-dariobin@libero.it> References: <20210225215155.30509-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfN5b3Rqft8U7sYPJxUkdMUWC1LS8OtnTPA11KZdrUvwXZNfnsJYRZ+Vn1uNUlhHDizOz33lXjueok4cZYUrttT9Of6L/P+Tc2dGCGoMKxQQs8KeSBVNo KtBLeHv0L07u/tTEJao2Ybhh4h/HrROJe/uHI3wOI8wwhIF9FSJCR9hgWWNJAtUzDYCwJWpVZPXit6HjCQOVeB0eo0BjmghmLlZOjLZPuK7+6Cg4rIDZIvCC 66o1nWgRniRAB8bjRte8XAxfZlxz8VtKCWDBverXiPHJmT57HaoZXGqUPDb4dZP8pufWDWCKWxdC9g2kF9XZU44SEzytO5YXEOzklNzuetTB57xyr5xlX/e0 Qi5W0claOPGkj+gpYTFmL3d36ZCQzR+C/U+pk2eNa0D53ZPiphE8MbFmgwTlfgCeuADde47OEwf+E8SddSKXeLFN9xhYmsu88aZehVdgu+g36I6NPDfA+RXB eDavfma1gpo6Vw/7NkzILVDeSq/GkSe5UQGvTlkhzhtGyp0+Y0GkZuEVSCE83lzB+NJLHfRMsZhofZe5qg6rfaIMuXpvJhl8FtSEQ7ffmCnGB0jDWBrkaTs2 smhF7ZLVjFugHl7vQ9rhfodC41wttg2vza7XzPP2RJcHa2qLtamUv3W7jzPVULpTK1o91l/DmcN48RD5epR8j8h8kUjVmTK0tRw/C0kWLn8bLA== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 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 7081cfaf62e2..df1ad6b3fd3b 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; c_can_inval_tx_object(dev, IF_TX, obj); can_get_echo_skb(dev, idx, NULL); bytes += priv->dlc[idx]; @@ -740,7 +738,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) { @@ -755,11 +753,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; /* @@ -862,8 +860,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) { @@ -874,7 +871,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; } @@ -1205,17 +1203,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 = ((u64)1 << priv->msg_obj_rx_num) - 1; + + 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..22ae6077b489 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; + int msg_obj_num; + int msg_obj_rx_num; + int msg_obj_tx_num; + int msg_obj_rx_first; + int msg_obj_rx_last; + int msg_obj_tx_first; + 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 Thu Feb 25 21:51:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 12105069 X-Patchwork-Delegate: kuba@kernel.org 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 2BA59C433E0 for ; Thu, 25 Feb 2021 21:55:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC25364EC3 for ; Thu, 25 Feb 2021 21:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234927AbhBYVzK (ORCPT ); Thu, 25 Feb 2021 16:55:10 -0500 Received: from smtp-17-i2.italiaonline.it ([213.209.12.17]:57611 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234708AbhBYVyD (ORCPT ); Thu, 25 Feb 2021 16:54:03 -0500 Received: from passgat-Modern-14-A10M.homenet.telecomitalia.it ([87.20.116.197]) by smtp-17.iol.local with ESMTPA id FOYQlNUJ2lChfFOYZlkbhQ; Thu, 25 Feb 2021 22:52:24 +0100 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1614289944; bh=zrB7Sex8qAljdk/P0favelF3Z2QW1uq0XCEp2nBu39I=; h=From; b=zFg22pCfjHhJMdOR+sy+LuWnSD883ppuuy4r1j+OLUD8OZi3/Z/eN8lArW956o2gI DimTwLEky5X1nlxEt24Maz7Ezy/036wTmws5DOvwSJ7Py8zcud+Y3dKlmOEgX3ChQh +E/lQmFQsJjUxL7XC+mXNAv4g/0cXkN3fWDtkY0kC/aLBrVp8LinGOs5gEwZUP0w6U +HrLuPMHCiE8mzT7CWE05uPl9v37Km5XMJ7PDYSk8X7l/NPc2C+FQG3DSiy7SzFciA XuO5fYSUwIU9GBMhzY8eEMpXL31pfeFbpgX/I1ElMaXkH9/COu64puz1MOAffti213 KP+fWD1xOzg5w== X-CNFS-Analysis: v=2.4 cv=S6McfKgP c=1 sm=1 tr=0 ts=60381c18 cx=a_exe a=AVqmXbCQpuNSdJmApS5GbQ==:117 a=AVqmXbCQpuNSdJmApS5GbQ==:17 a=FEz_7PL0ERQs5GQP_jQA:9 a=EQGfsiorO9qKaa_4:21 a=GjewnYaElfTv6_oh: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 v2 6/6] can: c_can: add support to 64 message objects Date: Thu, 25 Feb 2021 22:51:55 +0100 Message-Id: <20210225215155.30509-7-dariobin@libero.it> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210225215155.30509-1-dariobin@libero.it> References: <20210225215155.30509-1-dariobin@libero.it> X-CMAE-Envelope: MS4xfFMAPA/Fi5dwIs8cvMTO93k73YNNOSJ+XOPpg8LGQMt4XZ8QrrHJje7xLkIJVXnqIzLOFqRhRo336KskWqnxd9eZ4HmEdqxckfyhh2LHUDKSRJA1YYKp 5rzpZ4H+dF+i8UencNPBJ3GT/TN/1eoX1tWFu+CQTSlWphgy6gNBrv0jsQBVHTFQUr9XMAh1SS75jvPOurnRnoxzkl4aEkRypio2syCkNSjWMumFa0faRO4p MCxNyyu0nCAS0ih4+n0uJReoAzMlycJUlAWL7CRgCYK09+Ehdmo1XdnrE5XBFT2A3s6HVpenAc0qyydAMrn9b+/TwKLINrtQ/GSgamKvdK4Fy77wV6SdHZfA v3JldOAneHbJojF7nRKmk9WfOGKqQ2AMTtcQJ0vbuVvPmX3VEhO85KejNSFvBPJiFmn6leH7GThW/PhHVQEk/X+JlVDfbbxvbzIS37dx2gfvyyY3Wcw9oB7Q 34hsBQuuZvuCTRMrFiytK5B58NVBGHqeM0B+D5yZM5YAvut7SZ8mpVPkiCAoLGW508lLLmhrnd2zUYwK2vQ351kTo+kG+TiEWmVmge9qGVc2smKDerLrNz2E qZYdx6Q0g3szkI6cKP+a7a/vuSTd1NiI+mK8SlxFgUh3LaEn4arURPAdamOv+IFr0fSmyUN6er8WX5qs2zmRCoofSk48sAiQjmlv39JDSSbKxQ== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 v2: - Add message objects number to PCI driver data. drivers/net/can/c_can/c_can.c | 19 +++++++++++-------- 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, 24 insertions(+), 12 deletions(-) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index df1ad6b3fd3b..b049e94543cb 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -723,8 +723,12 @@ 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); @@ -834,7 +838,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; } @@ -856,12 +865,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 22ae6077b489..cff24597be3c 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; + 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..2cb98ccd04d7 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 */ + 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;