From patchwork Wed Mar 15 11:05:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70139 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2266981wrd; Wed, 15 Mar 2023 04:19:37 -0700 (PDT) X-Google-Smtp-Source: AK7set+iN5f5kjeAQKQAbRugxRMWfI1PWZzqn7jlryMbmjkSax+0+cNcrzdOQ1zDx3PPTkKE3zJR X-Received: by 2002:a05:6a20:1614:b0:cc:aedf:9a1e with SMTP id l20-20020a056a20161400b000ccaedf9a1emr47651738pzj.61.1678879176749; Wed, 15 Mar 2023 04:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678879176; cv=none; d=google.com; s=arc-20160816; b=jrFM7QsxhWqSwDIoSMy7RygC/0yzd+bSti23sP6Jp45F8QO9dpHujC7zkCW+zGPNSz a7bvqSXcDKptzHrnNd06mx8ZO+Adb8riap8faY9Azg8ZhDYG4I60bv/fZM3hJD4U6h7A X1dwroNd6zg1xc9o95A/8XYnB/au0/brAJrCw6Lsv2b8OaklXN/+SE9gAj1pydk907nj yIHTXLquNBe7BadTn5Gnb07AyzUazLubIYjVKvlEqiR9htyl/xZiuqtpk7NOpR93DaMB CvqV1++9HKg3SJV0YyP5vPcv9FL61aI0iNpMqVuf9TzPiGsPdRzbqgCpcC8b2CEcd7GF ofHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vPa68xqtezsL6sMRTVQ0tfny5rcXKUsYatwd7qGowxE=; b=gV27YbFPE5MZq0PUiNYmuBHZjobi8qeOm96CaTZc4McvEot7PUlAMHBgoscjoOdCDc /yxEasC3z0Q1bRo49fOdMIlBk4HBnu2bXNYmbuLbopxth/VLYTMmEnczj17+R6i/gF8r bv2T68IDC3J58WyyKYbWsMPwa9WJbYf3pO/uCJHaS9odtV0eiynhAFChLHWbWd3bO128 bGXubpS/OyCNq6lSNnA0WeG/ZSIy1JE+eu+vNMyVjMXi8r2wF4JGkd3+V+1I6YumbETF UXouHbeRvfqMFg8R9isFmZiRokOc2cKqZ75avUCAZbPAK15xxEvID5UCqF2maQmZvNUb 6GMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=6WZgOzyy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a12-20020aa795ac000000b00608f52c3f20si4783266pfk.302.2023.03.15.04.19.19; Wed, 15 Mar 2023 04:19:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=6WZgOzyy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231730AbjCOLGo (ORCPT + 99 others); Wed, 15 Mar 2023 07:06:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231513AbjCOLGh (ORCPT ); Wed, 15 Mar 2023 07:06:37 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BECC84F5D for ; Wed, 15 Mar 2023 04:06:27 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id p13-20020a05600c358d00b003ed346d4522so676765wmq.2 for ; Wed, 15 Mar 2023 04:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vPa68xqtezsL6sMRTVQ0tfny5rcXKUsYatwd7qGowxE=; b=6WZgOzyygg0zRDnl3x/YHL5WQkORuaTJ3lR0M74jAepA1G3LCh5lIi/ACzhN23kh6t DB+ETgEBdCDGDFCnDfn3UJVs6avbYkgcoKaSccEQ81OtapN79fKP0F/WPpFDUiKQyG6P /c7z4V6opxq/IodaPmKHbrA60YSsQE60iMQsV53eOC6rlGVvK3B2WN1l3p0OfLA4eVzN Qy2mNmBD7eYw4lPY/dAFHwoGRdr9CKiguskEkiqoCIbi1FgJJ/1dp/DI2M3z81VxhVbN Gb7VqWDnGcd/ZDQ0JxaYqBEDLrWJkiOMyhGj+zpULJC8v1D/R3D8WIboM9nepXMVC8dg rrEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vPa68xqtezsL6sMRTVQ0tfny5rcXKUsYatwd7qGowxE=; b=cHOlQYJPy2MZjU/zELIYTwojEPBaCovYXdenzPFvC4y+cskfi4Wqa1GBJAHIVKhV2e t56sIeb6LkHhcK3sVen/MdYIUc7+ia3byC+SmMBLPOij/UpYPcQqJzo3nP9ljO5wyvmb RRCP0Ae7vQteOeO8iblzImWTB0+s7HXtfZBrPq7VVUfwk7nJ7PRBo6S/Y2nwdJLxOSmj vxQvLKnoAe6VoqUgl07loYuOciQHecq3KCTaDfv7V+ikkl1S9EQzZr0oaHnpDhEmARjR 51TKS5z3no/MJ6Do8dXJDE4JxkbsAacn62A8PrgVWdf/B2fO1sQ+JdQWPCkwoN4uJbb4 3xYQ== X-Gm-Message-State: AO0yUKWjz+mCG46L6UfOYd8J38bkM/gFDGYziEWzF8vQMZSNSfMltsrR 5/mk/n3dVrRvLp+pvMiOn3MbHA== X-Received: by 2002:a05:600c:548b:b0:3e2:6ec:61ea with SMTP id iv11-20020a05600c548b00b003e206ec61eamr17703012wmb.28.1678878385936; Wed, 15 Mar 2023 04:06:25 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:25 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 01/16] can: m_can: Remove repeated check for is_peripheral Date: Wed, 15 Mar 2023 12:05:31 +0100 Message-Id: <20230315110546.2518305-2-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760432411871209094?= X-GMAIL-MSGID: =?utf-8?q?1760432411871209094?= Merge both if-blocks to fix this. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 8e83d6963d85..563625a701fc 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1592,10 +1592,8 @@ static int m_can_close(struct net_device *dev) cdev->tx_skb = NULL; destroy_workqueue(cdev->tx_wq); cdev->tx_wq = NULL; - } - - if (cdev->is_peripheral) can_rx_offload_disable(&cdev->offload); + } close_candev(dev); From patchwork Wed Mar 15 11:05:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2267794wrd; Wed, 15 Mar 2023 04:21:47 -0700 (PDT) X-Google-Smtp-Source: AK7set/Y787FYTZh7YjllIv/VarZph8IulG1DkAG0oe8Ei8kGsJHLq7sTnb51VnFZvyB3LwIiAeP X-Received: by 2002:a62:546:0:b0:5a8:c3ec:e24e with SMTP id 67-20020a620546000000b005a8c3ece24emr29231134pff.4.1678879306904; Wed, 15 Mar 2023 04:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678879306; cv=none; d=google.com; s=arc-20160816; b=Hz6UTn8Ewu4t60WIC94zgq75XqFhSov8UOwKEDId+00IC8I8CTzB5h6azkqoD95lRZ XhRD6hH41RmjppYbyifjSG34lkbRyeQ30kEx40hjLvHcLAR9evy+sX4hKMx4x0RMyAJo wILX8yoqeO+M4GecBqmFX3vPLUBgEEKqrjg985It+65nQSPM/H1Ex0GSoCTQk8dIGOrT bnoILQu23gJjNPV/Vr2XNmsEDDCYLWAXvyivyU3eyWSSfXRXp39hzsaKazN7ayDwutDh gRHp3X+LOescv1CIbPHu+g0NQPMYGGDlGppclifFUxp8a5pUn0ETGldOinfYwdZtnZ8+ MDyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k88g/tLODmL/T9qHyAnmUHflunm5no0E2q2FXlPGb3k=; b=0Wo94TYmLPnYy7v+8LAkXG4QHomU3SHx6rbuAi5o8x0WeQnGOKIbAH/aDF2eMNuE2l H1EO5kqcrFQmzPYAdrKdGM37//qx60Xp7EK3drbYZr41H7tmj8U6TNufOGxeyNZX9g1P LPV6J/Y0u8CbN04LnpiVZ6YWDawmkNN9GvOB1xRkq5KFVx0J9UEeh8su1oq216174JUL ZDyxoqyiPVZXFTv+Spziw2CLrovS+MbSsiVMkHDEcZKxuk45nCBh1XBqSl0Sw5/4p+SU 4wLuY/eQi5CiKHnAUmfCgd2dQlu3AlwC0sPearAlf2uGErLqhCkJ+UoZ3b6pod8ICydF O0MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=iZKxW14R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020aa79423000000b005941664b506si4176086pfo.224.2023.03.15.04.21.32; Wed, 15 Mar 2023 04:21:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=iZKxW14R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231924AbjCOLHE (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231225AbjCOLGh (ORCPT ); Wed, 15 Mar 2023 07:06:37 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D2A884F67 for ; Wed, 15 Mar 2023 04:06:28 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id m35so2734415wms.4 for ; Wed, 15 Mar 2023 04:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k88g/tLODmL/T9qHyAnmUHflunm5no0E2q2FXlPGb3k=; b=iZKxW14RgsUryqrI2nACouoY4HQvKFciZnX+mzVHzb7eZV3v+LaHyKH6USAN/IZzTa 5wAVzBLUhv9sOWCHw0z6fwn/24ZvPbn8W/HFQEJZ4UIfjuSR8E+Tim2vIAPXenbZhbiZ NF4Jbsy7kQC1hPp04+n2TDP24eYex0b0+D1fX6ah5B/35LvyaYuYu5Dn0ghC+1W/7Sz9 YSdHSqymvR1SzogEzO3nuIsqe4s2LgO1F3YqJwXND+mollBw38h8Qb6C8X06YaIxzODx Ylj30ZPDF9xrTAPLrv5kFEo1jW5DZG5w3Q/gfl0xzG54ZUXC7ZdRTnbN5/GAvPqvXQGb kvOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k88g/tLODmL/T9qHyAnmUHflunm5no0E2q2FXlPGb3k=; b=x/SiM20yDSt+Hc42yn/g4lzQ7vPDYo03jlsgxEnmk6UalALWEuE7pDbXQtltmir6yC RMBg+jHgoTiPf+ZRfKp71ItO4qVHDgISnBTl57R9HbY3dBzMvKeYXqgBb81zT3wH2TNU wg3FxfNwapo2hQhqlOA8XlZxxmojWXU4npGfOLy5+G7U8ih1grmx+fRMlTqSUZRiLn4T laCld7lzXoDQWYVnLR5V0klwZJpMFX4Ff6kNIbypDgoeqeHt6kitNFBddKqUOwp+RGQN pDvGAz1GB5U0Au6FmUxVG4srPOX5XM19d6XUG59UTUHhx0nITLQIR9wzSS1hJ9ppcIrV 96DA== X-Gm-Message-State: AO0yUKV5Xa8sSPhvEhU8+wLv57N/1KMWbvTtG+Gjbhlj83LPDwBgRJF/ Sdb/o2PHnt7O8WsKKX86V/k0MA== X-Received: by 2002:a05:600c:3107:b0:3dc:55d9:ec8 with SMTP id g7-20020a05600c310700b003dc55d90ec8mr16335974wmo.41.1678878386783; Wed, 15 Mar 2023 04:06:26 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:26 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 02/16] can: m_can: Always acknowledge all interrupts Date: Wed, 15 Mar 2023 12:05:32 +0100 Message-Id: <20230315110546.2518305-3-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760432548004741057?= X-GMAIL-MSGID: =?utf-8?q?1760432548004741057?= The code already exits the function on !ir before this condition. No need to check again if anything is set as IR_ALL_INT is 0xffffffff. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 563625a701fc..8eb327ae3bdf 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1083,8 +1083,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) return IRQ_NONE; /* ACK all irqs */ - if (ir & IR_ALL_INT) - m_can_write(cdev, M_CAN_IR, ir); + m_can_write(cdev, M_CAN_IR, ir); if (cdev->ops->clear_interrupts) cdev->ops->clear_interrupts(cdev); From patchwork Wed Mar 15 11:05:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70125 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2261833wrd; Wed, 15 Mar 2023 04:08:11 -0700 (PDT) X-Google-Smtp-Source: AK7set+cX7Jyg2cUJJVocfKl651/TXbZ0xTHhFT+xZF4jcq3fWW+rgn3lhbK1RcWk/CUI85oTB7k X-Received: by 2002:a17:90b:4b44:b0:237:72e5:61bd with SMTP id mi4-20020a17090b4b4400b0023772e561bdmr42389071pjb.49.1678878491111; Wed, 15 Mar 2023 04:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878491; cv=none; d=google.com; s=arc-20160816; b=d8hRiVTrFomDru4zjlKugNUw9IP4tDVl3fPQpn+PQSWeSzlv4Gic9LN7vlXEWjgRmy gRCWTr+GdUni/v69QCYJnvM7SMp3VmlWoHFidw8GupdKovAwvoqMyAUpsKXtcqksuXdd os334ljnINCb2sIR7Fb+vFAq5xSnGQgGR2rgmiJ7CrCiVWvr2AJnyUM+ydtWJucEu9K2 FVFQltd/2phucFw4leodo3gQQHkCFPK0lO4rYRYhFu0ExQemQOm1Zu7kbHYxBOhtg5A+ GoG1+ZGo8q2MloaSZWWQJeG66dyuUVYenHjCyphcC6uycG3AWv50EsGF1LcqshP6AaNq 7eEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MFEvCUdnRPRdEAvOdxaVu4SNhrWUtZmDw6TEQufRunU=; b=acpiRZXQHzhoXxZtTQHgqCYIUhPgf91fMVqRpvKeRehckbXQiih25WnR3/yeN9XMvI bABQSR+/c+INcSXsORQcocX3CHNtW5dsCj02I/94r7820eh42cayySWz5I2L+1lPvfgX 5lps4OMtKqHlM5plkVO1b7A3spkE6KrcLySP+14ezRjyVfzuzy5Ln+9AXuSNalvEM5f2 xRmQOF4UcURxCGft7pmRzmPrxczsm/mrbM8DmQn6bAJMNAIOWu1yUpN7xuLQGlNjlqZ6 6+eWV7voF1VwkxhqvtWIG8tgE8bXtY23MAb9zJahv576D73eb5k8IOPojF0ayrB593CH mopg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=KS43ZTNY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v7-20020a17090a898700b0022962fb35b8si1379799pjn.133.2023.03.15.04.07.57; Wed, 15 Mar 2023 04:08:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=KS43ZTNY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231903AbjCOLG7 (ORCPT + 99 others); Wed, 15 Mar 2023 07:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjCOLGi (ORCPT ); Wed, 15 Mar 2023 07:06:38 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2613784F74 for ; Wed, 15 Mar 2023 04:06:29 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id l7-20020a05600c1d0700b003eb5e6d906bso899113wms.5 for ; Wed, 15 Mar 2023 04:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MFEvCUdnRPRdEAvOdxaVu4SNhrWUtZmDw6TEQufRunU=; b=KS43ZTNYzVEwCNAosKlEcPLE7wlEorxUCPylz22zHpjrLp2O32kxKqoGop9phNxZhx H7kEJk8Oud8dLYHl8cmHdBD8cahGDK4igm0HgpjevqcdWrJ3HwLCG4YFvpOSzQtn9oTA YzJUxM4Xz3vbBzwqs7rset/Xb7HCPzvjPy6p0uKGvOStRzh1jxJN/hO6mj9sM39FzOj3 XhbGN0NZd8xzZpD1W+wmS9PZplcjZyZGqorTuTyQP//waoX53JVOfPuWp7lkMzgqr5SL qVSRXIchxT/l9e/aNeJ/S1K/UTr9gARXQ1r1spczeP6JHW8HAnY/BOFDOy+TUb4H3G3W UZ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MFEvCUdnRPRdEAvOdxaVu4SNhrWUtZmDw6TEQufRunU=; b=GYI+e97yE4p0slwUkT0s7Ucm5pnZdM8Hmwnbi8RezkjFFx0g4YMWCOzelu3JdZm+nH m4nkZsgOJ6SN4hA8P1TPIKlLaH8EwyqEtcmt0IBCDqS1fWibQ/KW+TF8fNGxtpY/lL10 AO12auTmdvISF7BbVwuGXGYZy0jglOOcHXdQUlJP1sAXBQXQPgZaxWYtns1rp69iQHtu sgkF2eJjGMQclf6lZ22QFwrxce6quHwGtfFDcxF9svidFY1wXI2znY2HCwVtNeZK92k4 1fhJEsVuqVmV4s2DPq1pa1OE8vhjb/AiAZeGRbZ8xsK682i1N2XXIp4+HUerf3GU92w9 e9Lw== X-Gm-Message-State: AO0yUKVMoKf/ydHFFjQh56f+NWaJt83pS7aHUEBi47q92s4mXJ8JGpbG KNSpnJuGFyRBPvGu13kwmqC+EQ== X-Received: by 2002:a05:600c:1c0a:b0:3ed:22b3:6263 with SMTP id j10-20020a05600c1c0a00b003ed22b36263mr11335233wms.12.1678878387621; Wed, 15 Mar 2023 04:06:27 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:27 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 03/16] can: m_can: Remove double interrupt enable Date: Wed, 15 Mar 2023 12:05:33 +0100 Message-Id: <20230315110546.2518305-4-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431692599647737?= X-GMAIL-MSGID: =?utf-8?q?1760431692599647737?= Interrupts are enabled a few lines further down as well. Remove this second call to enable all interrupts. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 8eb327ae3bdf..5274d9642566 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1364,7 +1364,6 @@ static int m_can_chip_config(struct net_device *dev) m_can_write(cdev, M_CAN_TEST, test); /* Enable interrupts */ - m_can_write(cdev, M_CAN_IR, IR_ALL_INT); if (!(cdev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) if (cdev->version == 30) m_can_write(cdev, M_CAN_IE, IR_ALL_INT & From patchwork Wed Mar 15 11:05:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2261794wrd; Wed, 15 Mar 2023 04:08:06 -0700 (PDT) X-Google-Smtp-Source: AK7set9FS8uA+znk6Iarv2PgsnIRd9oTJVYtHK9bfMVQra5lFf8mbsFueUV41LrcjmtiEQtT8R4w X-Received: by 2002:a17:902:f291:b0:19e:dc0e:126a with SMTP id k17-20020a170902f29100b0019edc0e126amr1751490plc.18.1678878485980; Wed, 15 Mar 2023 04:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878485; cv=none; d=google.com; s=arc-20160816; b=zN1c+R5hCeVUdmLnP88s76Yd3RHgsW1eJrSWx6PVW/wW6Av7/XxRIxAXwQsPsTQVVo 5IlYtVY2vVHEXm3Ff8fhnKvm93lTCrrPii4h6Lr1alnws1Jh0opdr4YfGiJdjB0jsbs6 x/TBiGBYLM++qfHCVBfDW2/d7Qg99LpNmqBGZzC0mqgmxVCIyyK25MES5rspdp0Kpb9z hs/iOgvdXeew8VBiQsOUgZ88yNK+wGlTCTBNhLiDUQuSC3bRV64/jLlQXXyOFa25AnXX UXHD0oCsKAaAcMa1HR0oNyVBmnmfohO2hxgz8dleZ5L6f8U/ujy63Ypq1R2MS/3lBSxh qYdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Jd8Qw6tYWP8+UhEwcLFiF9jauK6KGSZvnf2iBpWLLhI=; b=Vszx7tN4czlQ99ejKhoL0o++ebVlT95NG5lUhBcAD5H3T1oZ9iXALPNyGo6GwyIZ9A ulyhU1sygwmuJwOiRyM0w8woGQQHoiqVrhV7wlM3onba5rwJeJb7Oq6dY3F5cMhRbiN1 EiqgPEoQGjzdrySfSnJsTA6zb7YDKS2Cusjn6UMYGChF/Q18+Rluy7q61tvV31dedSIn L7mZRQDDPXaiaza+uwqBZK3hlxxcwRuphitvOGxhMHbLJuQIYn1n5T/Rdb7yA+SxJ1Fn 3oYHGigOzhNspEvJT2RiBsG/EG+RR+JJG+s+4u0HTmzrDr2GCcuM1dGJD+MkIQtr3mJ3 bb8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=bFwVnfvJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jj21-20020a170903049500b0019a88f51635si4608737plb.534.2023.03.15.04.07.52; Wed, 15 Mar 2023 04:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=bFwVnfvJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231841AbjCOLGu (ORCPT + 99 others); Wed, 15 Mar 2023 07:06:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231545AbjCOLGi (ORCPT ); Wed, 15 Mar 2023 07:06:38 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E82FB8534A for ; Wed, 15 Mar 2023 04:06:29 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id y14so4248802wrq.4 for ; Wed, 15 Mar 2023 04:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Jd8Qw6tYWP8+UhEwcLFiF9jauK6KGSZvnf2iBpWLLhI=; b=bFwVnfvJ+2RaVkxVOt+DW/N4wkI25kazo0eEW1ub/25j6bkDQFg0tFKk/f/Cw5vQ9h J/RNV6QKkAGFZ/y+Kiq8T1oDguqEisdAQLpOVWUatyJvoflbkv3Jve2MT2Cif2HQS4ER w5IpcvwsU48czgn46o1G9RNRl7O4tmmd2GsTlnmTnf8Bu93NKR39eogx8Et2RhqF/VJH 7mQ8o/MnN2q24L00qA7jOMPPkPp0Nw9AXOyLln6mJUHyPBNrBqXDDpmCRpaYDqXPpLeg ifdnIcOJNxo+zXJn0JMuAy8QqkthgHP/hJl67rKIDNZFJTyuKYXfAnaARRdQQgBph4pd DAFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jd8Qw6tYWP8+UhEwcLFiF9jauK6KGSZvnf2iBpWLLhI=; b=Kd1FRGmlGMQFrEVFF8B+Sc8kMIOn/r+QqMXzGKuGag29XEd1j2tHHlXwNsofgDdMOn 3g9rPj0zQSamCdKmyjZJc5BayBz4+8tvcz4XgMk+W/dU4D5ujuFme6Tl1oQx0zHeuVec C1q/VPYO4C6lZRbYzwOpe2foXS4cNmmK/iH4w1adWO3E6c5of95jEED0CS3poGV9yuvt LXsl0RKTrFO5SzjIgM8Pclt3Bg41rz8QEB3FLntJKfm0utMHJqqRScddK0hGSw5UYQAW TJRY3VZRlXU+/ZoXr2FKWDw/eZKSglEZYqB5dYY2S2lSBZT5994UYxP6BKQmAcXpVmLV BcDA== X-Gm-Message-State: AO0yUKUBf/7Wqz3sqJKua1U8dLwXPV3Ila+hrchjQvlF+fXziY/F4ERp x1/2uZdk+tiXTOn+fQ0cBOkxsA== X-Received: by 2002:adf:f183:0:b0:2cf:f30f:cc04 with SMTP id h3-20020adff183000000b002cff30fcc04mr1545606wro.27.1678878388478; Wed, 15 Mar 2023 04:06:28 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:28 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 04/16] can: m_can: Disable unused interrupts Date: Wed, 15 Mar 2023 12:05:34 +0100 Message-Id: <20230315110546.2518305-5-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431687041659907?= X-GMAIL-MSGID: =?utf-8?q?1760431687041659907?= There are a number of interrupts that are not used by the driver at the moment. Disable all of these. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 5274d9642566..e7aceeba3759 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1261,6 +1261,7 @@ static int m_can_set_bittiming(struct net_device *dev) static int m_can_chip_config(struct net_device *dev) { struct m_can_classdev *cdev = netdev_priv(dev); + u32 interrupts = IR_ALL_INT; u32 cccr, test; int err; @@ -1270,6 +1271,11 @@ static int m_can_chip_config(struct net_device *dev) return err; } + /* Disable unused interrupts */ + interrupts &= ~(IR_ARA | IR_ELO | IR_DRX | IR_TEFF | IR_TEFW | IR_TFE | + IR_TCF | IR_HPM | IR_RF1F | IR_RF1W | IR_RF1N | + IR_RF0F | IR_RF0W); + m_can_config_endisable(cdev, true); /* RX Buffer/FIFO Element Size 64 bytes data field */ @@ -1364,15 +1370,13 @@ static int m_can_chip_config(struct net_device *dev) m_can_write(cdev, M_CAN_TEST, test); /* Enable interrupts */ - if (!(cdev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) + if (!(cdev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) { if (cdev->version == 30) - m_can_write(cdev, M_CAN_IE, IR_ALL_INT & - ~(IR_ERR_LEC_30X)); + interrupts &= ~(IR_ERR_LEC_30X); else - m_can_write(cdev, M_CAN_IE, IR_ALL_INT & - ~(IR_ERR_LEC_31X)); - else - m_can_write(cdev, M_CAN_IE, IR_ALL_INT); + interrupts &= ~(IR_ERR_LEC_31X); + } + m_can_write(cdev, M_CAN_IE, interrupts); /* route all interrupts to INT0 */ m_can_write(cdev, M_CAN_ILS, ILS_ALL_INT0); From patchwork Wed Mar 15 11:05:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2261980wrd; Wed, 15 Mar 2023 04:08:28 -0700 (PDT) X-Google-Smtp-Source: AK7set8EiLWbj5UIwcHXqW5bAPsdlNKI94KJPuN43nFULpw2J68AzHjNYE6kva4YctdN9PHkvhq9 X-Received: by 2002:a05:6a20:699a:b0:d3:e7da:c3eb with SMTP id t26-20020a056a20699a00b000d3e7dac3ebmr17200970pzk.11.1678878508128; Wed, 15 Mar 2023 04:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878508; cv=none; d=google.com; s=arc-20160816; b=ydC0OKpVUhL81021N9fROUmDdzhK6xaWNGZTLZO4bBIxDoj8dRrwP9HZSJioU67U6s lrhxd7ETIUj6a222kG2RI35LpqzFtc12WVXN4GF9DVo1HVVTDrQGQBhEPyxTbBIvxRca bb2fypM+/MKnSYbFVO/Ya4SE9fc30Fxc8gFFtIafHkEaEtkot576kGHLggqEjjkW/jIZ WNGpkWYvnkommHmId3Xth1c1qo4p0W+zh2LMbPYqM3p6YwaAIrLudvOO/mfhmkNe3Dy/ iZ8EJoiJBu1TShysY2KJzEb0f4oKSt5lskD9dDINag1mvMjHqIfv2lZJh6uVimTEb+C+ 7JBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YFt4bxPMCgWg0M7+jSOYYgnyoXJC6PqUm+WV19TP9H4=; b=GkUbjuArID74pun27k4uU8HyPgh+9T9LE/gqfaXXIuZxwrQC6TsQNcIoGJRA29lFSG s9oDw6usVzJqyq/2eG7mnFSaZKr5+7AO0a0XRR35jUbCSfjK4BJQT8aBmAHp09FYhueJ Qq1BAYuvElBEsagFmJoOQ+cbxKs1RmZtSAdbxRmbEX3D+Algx/D21Fwm3orD/qHoKPBb a8hdMRUA/rh5X/70EbQCcuzrJtULBjNuGtKE18UNnkhAeQ0jY5sbzzcdyMmE3/yJb8fP UFxcMEoV70DsN8T4W5rzuNUCrxBl/5eAqxoeR9xEC4fEkvYWf+Yv8NsFoYKFpWhYsSyh vU1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=osaePjHp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e35-20020a635023000000b004dffd0e0409si4602558pgb.518.2023.03.15.04.08.14; Wed, 15 Mar 2023 04:08:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=osaePjHp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231861AbjCOLGy (ORCPT + 99 others); Wed, 15 Mar 2023 07:06:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbjCOLGi (ORCPT ); Wed, 15 Mar 2023 07:06:38 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA3AD80936 for ; Wed, 15 Mar 2023 04:06:30 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id p23-20020a05600c1d9700b003ead4835046so1872495wms.0 for ; Wed, 15 Mar 2023 04:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YFt4bxPMCgWg0M7+jSOYYgnyoXJC6PqUm+WV19TP9H4=; b=osaePjHp3RUs+eN/4I1mDejB79EY61Itw7Y16r9hbWxfv60LpNsBSXMxYcff1nEF1c H8D8bgR4ayHvgrZI3fTPQ2JyhzgVCW4VnvK3AgPtvJwaay44H7tBzD6tFtb7YkgaAKWk hsZRE+xijpqBCm7nXKZOhdL241g749MaTKmbjyWkKm2waIJ9+JK8KYDSzWbbgHdQ1xqQ YftE5KtMuine9O4ukfkBRPqc18/jrD7DcDn8gkLMYw5oc8QZz5DY/xiCYDVyUmAlHUx3 5KYJzKnbbrDptDcsUgpq920v8ulCVVxnhqLaULtjbge8DyJ9u/pYL4e0/v2HdJTlLR/b rqeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YFt4bxPMCgWg0M7+jSOYYgnyoXJC6PqUm+WV19TP9H4=; b=pE/1VuBDd4+I1l23OFteOFNqcEsZPK4Gji5auvyQS6ZCLzg011fcdRKalF/2+vaIN9 EHScQkoxKJIj2xzfJpLpDPvdSbhY3QJlv6arE+4aJOfg+On2DZ/K2TW1yr/5IEDeEDvo KdlgoIb0NqUSJxxBNFp/dlsQEE9jY4+UeJsZQOEWKyOjerQqA6Yf/Xbl8yGt0MMWPq5e Y0ggHO1IXqXDxDwlGvo7+20krAnhzDdi3igBL8MQ3mkz+olmTc2EeI1ohyUj6PvVrwxD 6dI5HZjUE/D5vOnho6y9CMpgtQZHvcE56/mfX1cHuCAP9bfg7Ro0XGUR+8sTwISAWVSX 9S7g== X-Gm-Message-State: AO0yUKUvJuhJ9hCYc8B4dzs0AIBas2Ivg9soeUvXwZNpGXOOMk6L9Yd6 v9EoKloR1iAJRcmwnzQlnDfG1Q== X-Received: by 2002:a05:600c:3595:b0:3ed:2a91:3bc9 with SMTP id p21-20020a05600c359500b003ed2a913bc9mr6268192wmq.15.1678878389346; Wed, 15 Mar 2023 04:06:29 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:28 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 05/16] can: m_can: Keep interrupts enabled during peripheral read Date: Wed, 15 Mar 2023 12:05:35 +0100 Message-Id: <20230315110546.2518305-6-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431710759529452?= X-GMAIL-MSGID: =?utf-8?q?1760431710759529452?= Interrupts currently get disabled if the interrupt status shows new received data. Non-peripheral chips handle receiving in a worker thread, but peripheral chips are handling the receive process in the threaded interrupt routine itself without scheduling it for a different worker. So there is no need to disable interrupts for peripheral chips. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index e7aceeba3759..a5003435802b 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -972,8 +972,8 @@ static int m_can_rx_peripheral(struct net_device *dev, u32 irqstatus) /* Don't re-enable interrupts if the driver had a fatal error * (e.g., FIFO read failure). */ - if (work_done >= 0) - m_can_enable_all_interrupts(cdev); + if (work_done < 0) + m_can_disable_all_interrupts(cdev); return work_done; } @@ -1095,11 +1095,12 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) */ if ((ir & IR_RF0N) || (ir & IR_ERR_ALL_30X)) { cdev->irqstatus = ir; - m_can_disable_all_interrupts(cdev); - if (!cdev->is_peripheral) + if (!cdev->is_peripheral) { + m_can_disable_all_interrupts(cdev); napi_schedule(&cdev->napi); - else if (m_can_rx_peripheral(dev, ir) < 0) + } else if (m_can_rx_peripheral(dev, ir) < 0) { goto out_fail; + } } if (cdev->version == 30) { From patchwork Wed Mar 15 11:05:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2262031wrd; Wed, 15 Mar 2023 04:08:33 -0700 (PDT) X-Google-Smtp-Source: AK7set9eBa53TzTe0Lwj6BE70b1vaDULM21+wm3dCU41ogY1gI2s7yByRzFquJbHhAjr+VmmbGrr X-Received: by 2002:a05:6a21:3385:b0:d5:909a:7955 with SMTP id yy5-20020a056a21338500b000d5909a7955mr6001598pzb.41.1678878512938; Wed, 15 Mar 2023 04:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878512; cv=none; d=google.com; s=arc-20160816; b=mXg52C9tVOCtU1CxWbWg6NCzt7YrUU4D6ojFf4VYU+vTCVvGbXZ2J1vf95ppcPm1St Dwe/lreATBhTveGAVb/0X9lP5Ok+O0/fxrhYidjXIB+f62q1r3R39s39CjS7+BJoQDRb 2mxiGeZCwwu9YqVD8n/UIQjcnD1w8fJbtXshi7TmBRl9kyDIYLMXXtiOznbQxKCu9yt6 3zzbErwuZJnwleg1OVbQOePmv+IWluLKG1N+QB1Ezjgani3yFgVEnFruBpPabkHrYRim qsmAycjhwpDbjMoJ2mDWN1lKXD6DvST2KlsGKuukMDWgl0ptdGtAtKovGih63LqZH9DF qi3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AWzMTugaKEGU24JeDUKp4PyFtC2GqEFZd+tmG3zdkvs=; b=wqM31tBwLOdwOXWJ/Rmk2iGxjClYNIAomPWV1L9EpJpng4wH0+57/sNwbShQyczMK0 6bdM5ZVBdWQvWwa6WIlYf43+KbJggS62dM51tjhNdomTR+k1NP0WbqtLLWV+BMOs2qp8 HFaqEoWcX7HW+dy3Aswtk63yeQQ59gpVGOFdpq+iMHrXXId4UEwpuXggryFBOOR5meFq etil6a1gTIAYEuS/7qOYBcLZZjn8KzGNScCrx8eby+7OjVab8hT4EE5Optr4t/3p4d+U r7g1qzUu3raGTVESOgeM67gcfhPZzCJPWUXDG4ItZFK+EZXNQywCSI0/TtX6UuB4N09C ED3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=cUaxpLaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 66-20020a620545000000b0058d9266a507si4364934pff.376.2023.03.15.04.08.15; Wed, 15 Mar 2023 04:08:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=cUaxpLaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231952AbjCOLHJ (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231552AbjCOLGj (ORCPT ); Wed, 15 Mar 2023 07:06:39 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6511785376 for ; Wed, 15 Mar 2023 04:06:32 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id x22so6809892wmj.3 for ; Wed, 15 Mar 2023 04:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AWzMTugaKEGU24JeDUKp4PyFtC2GqEFZd+tmG3zdkvs=; b=cUaxpLaDj2CX/ggiG1GSwL+CdNwizAvaSK9qroa7Rui1suiWOwy0JnQ16qOH5qW/2X 5+nTb0rFL5sRjbhFIWk9txmE2FoED82X81p9HVzAo7h7MRdKGOhX2Gh6Gv3f+JyAy0io RQCH7nskO1uSPK4Ff54wAoZ9EXIC1/7W8CQfJyxMYA1Z0DDCdsEFP767DLYDaKjq/Wj1 Zwl96VzTrPMpg8E/eH8FqIYwSMbBgFaaRTtAGvBdBleIB8b/uqd7X69RKNJ3T5lLIpG9 HgsYsojP9loQANiJAwTYfww9BNaAiol1NKXTb3PeXTGoa+uO9yFAUHWpYUPCf0zVzAef 1KOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AWzMTugaKEGU24JeDUKp4PyFtC2GqEFZd+tmG3zdkvs=; b=gzg6zHnAAgAP4K+0A+WLFBto32O0e1IDxMMX0hFqD5aXtJFgGsKbw3QiyTsipFU9Mm v+Ea9YCpvvGYubQXpOWzcudbXXW9Lc/QUjUOdZbTlvlVV9lG6LWHcF//7z3rz2PZLTia uS977lJcD39Vb1jSdgJRKNb+YGo8yvWV+R0QsO5OJ/iyeu0RK3eRK4KVY3aGCaqZUm40 8WlvlBnih6DuW1QZIxnLqg04G/zERuTDm9ManTc6z3uOq5ZdNdwwDTDI3k1E+8KDlrZp ddYDpc9Rvf8BjtcdOEEWz5NuNbmFEBYsiKFBdAJbYxfTQgxG/YcU4YYMI1ijAmHeeM0Y YUXw== X-Gm-Message-State: AO0yUKVX7YnNaxH2shFQiz5pLNRQzYRqiOvuiqzMHGAvXUs3Hjssc42B QvAqBY//dVQaNtkrYZcpjw6GMg== X-Received: by 2002:a05:600c:470a:b0:3e1:bfc:d16e with SMTP id v10-20020a05600c470a00b003e10bfcd16emr17411428wmo.39.1678878390167; Wed, 15 Mar 2023 04:06:30 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:29 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 06/16] can: m_can: Write transmit header and data in one transaction Date: Wed, 15 Mar 2023 12:05:36 +0100 Message-Id: <20230315110546.2518305-7-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431715532254106?= X-GMAIL-MSGID: =?utf-8?q?1760431715532254106?= Combine header and data before writing to the transmit fifo to reduce the overhead for peripheral chips. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index a5003435802b..35a2332464e5 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1681,6 +1681,8 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) m_can_write(cdev, M_CAN_TXBAR, 0x1); /* End of xmit function for version 3.0.x */ } else { + char buf[TXB_ELEMENT_SIZE]; + u8 len_padded = DIV_ROUND_UP(cf->len, 4); /* Transmit routine for version >= v3.1.x */ txfqs = m_can_read(cdev, M_CAN_TXFQS); @@ -1720,12 +1722,11 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) fifo_header.dlc = FIELD_PREP(TX_BUF_MM_MASK, putidx) | FIELD_PREP(TX_BUF_DLC_MASK, can_fd_len2dlc(cf->len)) | fdflags | TX_BUF_EFC; - err = m_can_fifo_write(cdev, putidx, M_CAN_FIFO_ID, &fifo_header, 2); - if (err) - goto out_fail; + memcpy(buf, &fifo_header, 8); + memcpy_and_pad(&buf[8], len_padded, &cf->data, cf->len, 0); - err = m_can_fifo_write(cdev, putidx, M_CAN_FIFO_DATA, - cf->data, DIV_ROUND_UP(cf->len, 4)); + err = m_can_fifo_write(cdev, putidx, M_CAN_FIFO_ID, + buf, 2 + len_padded); if (err) goto out_fail; From patchwork Wed Mar 15 11:05:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70133 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2262424wrd; Wed, 15 Mar 2023 04:09:22 -0700 (PDT) X-Google-Smtp-Source: AK7set9tAVy/Hbj0WyEVfzkswU8VxL+0vY/Q2Y/ZbETcgIILiBGcuoOL833OqMior7WcDW+0PbhZ X-Received: by 2002:a17:90a:7489:b0:230:7a3a:d4cc with SMTP id p9-20020a17090a748900b002307a3ad4ccmr41564830pjk.43.1678878562104; Wed, 15 Mar 2023 04:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878562; cv=none; d=google.com; s=arc-20160816; b=Fnij4cLrXIWZ6wxX2iax9ZgurKec7Qw6FtYKYzC887TKxLAAAkdmBGoSbJ+iH8x1ZJ qKsLKVPY3Yi4VxUJUF5MdcX5MkNGM4m27v0zrrqpmTtRsc1Xn368R1i3rpYJxLI1J3Up AlhZxSZSw+CWbMAanez9LXx7IXeD7gV9xn1gFt2XLy0ICSScWur/AX5+w2qtttUuxBrs +qhRLEvvGfTlfCZYlbECG8CqDYlkWUKOB6f1CvoRznrVUCPmy/1XpTSC+42vr/dQRHGn 6ItaWyO5BpXukKhzepDGAgFodTze8tlF8dtvhUnwFXFzlpzRlopKoACUWwQIjTVuPr5i I8bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4G51EsWXQSEVtcp1NG3mD14IHUOx70eoIPFV54V3mcs=; b=eI9jErNE3YZbspEL2mEPH9Zx2nrgm1jw3oRb9vBymgg5XLtcVqIbd4/uGlB/9NS2tP zfFxeJ4yBPwpHpHWnc+hnu07ZlYs22TZ3yM3aCXmybeuAy/UWQw3R+kj2AUbGA0jmBVC xBJvJGtl10mCB37irzDmfd3CC6G3Ji5ILvMvLQPKlfMZ5RkGmYl0YWnToRiMpU5UxwWp OeYVtxLBOUSlMqtx1u8RNzVFEQ/e8/znvWgU1Wv8kxLFbMlbFckoIjQVfbmXPp/3vN6P GR7sSdFrFghnk3raipsziSsLq9SQAy4yEiky8NllIz3sD7/4GFZLGYLQZ8FbibyHf6Gb UhSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=72BvkdAD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gp9-20020a17090adf0900b00233866f90e3si1340359pjb.125.2023.03.15.04.09.09; Wed, 15 Mar 2023 04:09:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=72BvkdAD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231965AbjCOLHN (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231481AbjCOLGk (ORCPT ); Wed, 15 Mar 2023 07:06:40 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3ED085686 for ; Wed, 15 Mar 2023 04:06:32 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id p13-20020a05600c358d00b003ed346d4522so676934wmq.2 for ; Wed, 15 Mar 2023 04:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4G51EsWXQSEVtcp1NG3mD14IHUOx70eoIPFV54V3mcs=; b=72BvkdADVNjAa//Jme41vk/2ZmgkszfBpEMKZ60sdwjtfF6qTaHNZzJmsTkwx88AqO sYYYbSDb+bDMGj0ThqGzZRhJDpBwtCA41s4V5c4SO3cLj75hEGAHmLiLsS1C8ZAAOdKZ BnDbuRc0Xd+0ZMz2OJF5QdH/IWXb/0M6cyWg4d2BMB3+52sarKFCxFrhDm2PecL+bDwe debh6WkcdC5yTFublpG7Bi/i+kj6SKVAM7IHtOgNOnAanQVGyKYtqkaJm4OSDoz5lHeW JYBxrt22Tp9gfXeSc8zOQt5dyyuTZs35OH/3K3RMy3889Axt4i0ZFuk1KaBmcqqckUfr PJRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4G51EsWXQSEVtcp1NG3mD14IHUOx70eoIPFV54V3mcs=; b=uWEuszOUdBt0BjGCuz6wvywBIEQuTFBql9UkhFdyR7pztpugw8bizRqNp6rn1rlF2K MdvKePKcyqvTQ4mHSccs9ay/dW0/JSmk15GEmqyGmkXG4gNAXmyPw10fXna5FG7bjtwP REh7J16UqWNm943X+7mwWQpsvEE1yrm7YIPqSHHmSox0/WmKLd5AoS732ptculfJrXt1 QY7aRZTb35Y/61Db2OS+tHFPZaqiYai8vQWj1TSJWPjYl3AG761BgojH/z9JFFwLxR1l L+OQTCaUa2k5988aiXPl3Pb/bxp61DYABGMDx+nMcr0930C4/aiarjPLCA2Z3HCgvanh bbhg== X-Gm-Message-State: AO0yUKUYrU0atZRhMJZFXU9Uk4m/dQ4P2/GMFgaV14RkIotb7z51RkkI ecaPfIL9vKP3nggjpC+pw2s1xg== X-Received: by 2002:a05:600c:4fd1:b0:3ed:377b:19d4 with SMTP id o17-20020a05600c4fd100b003ed377b19d4mr551186wmq.0.1678878391024; Wed, 15 Mar 2023 04:06:31 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:30 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 07/16] can: m_can: Implement receive coalescing Date: Wed, 15 Mar 2023 12:05:37 +0100 Message-Id: <20230315110546.2518305-8-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431767061498574?= X-GMAIL-MSGID: =?utf-8?q?1760431767061498574?= m_can offers the possibility to set an interrupt on reaching a watermark level in the receive FIFO. This can be used to implement coalescing. Unfortunately there is no hardware timeout available to trigger an interrupt if only a few messages were received within a given time. To solve this I am using a hrtimer to wake up the irq thread after x microseconds. The timer is always started if receive coalescing is enabled and new received frames were available during an interrupt. The timer is stopped if during a interrupt handling no new data was available. If the timer is started the new item interrupt is disabled and the watermark interrupt takes over. If the timer is not started again, the new item interrupt is enabled again, notifying the handler about every new item received. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 69 ++++++++++++++++++++++++++++++++--- drivers/net/can/m_can/m_can.h | 7 ++++ 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 35a2332464e5..e7dc083e32e4 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1070,15 +1070,55 @@ static int m_can_echo_tx_event(struct net_device *dev) return err; } +static void m_can_interrupt_enable(struct m_can_classdev *cdev, u32 interrupts) +{ + if (cdev->active_interrupts == interrupts) + return; + cdev->ops->write_reg(cdev, M_CAN_IE, interrupts); + cdev->active_interrupts = interrupts; +} + +static void m_can_coalescing_disable(struct m_can_classdev *cdev) +{ + u32 new_interrupts = cdev->active_interrupts | IR_RF0N; + + hrtimer_cancel(&cdev->irq_timer); + m_can_interrupt_enable(cdev, new_interrupts); +} + +static void m_can_coalescing_update(struct m_can_classdev *cdev, u32 ir) +{ + u32 new_interrupts = cdev->active_interrupts; + bool enable_timer = false; + + if (cdev->rx_coalesce_usecs_irq > 0 && (ir & (IR_RF0N | IR_RF0W))) { + enable_timer = true; + new_interrupts &= ~IR_RF0N; + } else if (!hrtimer_active(&cdev->irq_timer)) { + new_interrupts |= IR_RF0N; + } + + m_can_interrupt_enable(cdev, new_interrupts); + if (enable_timer) { + hrtimer_start(&cdev->irq_timer, + ns_to_ktime(cdev->rx_coalesce_usecs_irq * NSEC_PER_USEC), + HRTIMER_MODE_REL); + } +} + static irqreturn_t m_can_isr(int irq, void *dev_id) { struct net_device *dev = (struct net_device *)dev_id; struct m_can_classdev *cdev = netdev_priv(dev); u32 ir; - if (pm_runtime_suspended(cdev->dev)) + if (pm_runtime_suspended(cdev->dev)) { + m_can_coalescing_disable(cdev); return IRQ_NONE; + } + ir = m_can_read(cdev, M_CAN_IR); + m_can_coalescing_update(cdev, ir); if (!ir) return IRQ_NONE; @@ -1093,13 +1133,17 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) * - state change IRQ * - bus error IRQ and bus error reporting */ - if ((ir & IR_RF0N) || (ir & IR_ERR_ALL_30X)) { + if (ir & (IR_RF0N | IR_RF0W | IR_ERR_ALL_30X)) { cdev->irqstatus = ir; if (!cdev->is_peripheral) { m_can_disable_all_interrupts(cdev); napi_schedule(&cdev->napi); - } else if (m_can_rx_peripheral(dev, ir) < 0) { - goto out_fail; + } else { + int pkts; + + pkts = m_can_rx_peripheral(dev, ir); + if (pkts < 0) + goto out_fail; } } @@ -1135,6 +1179,15 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) return IRQ_HANDLED; } +static enum hrtimer_restart m_can_irq_timer(struct hrtimer *timer) +{ + struct m_can_classdev *cdev = container_of(timer, struct m_can_classdev, irq_timer); + + irq_wake_thread(cdev->net->irq, cdev->net); + + return HRTIMER_NORESTART; +} + static const struct can_bittiming_const m_can_bittiming_const_30X = { .name = KBUILD_MODNAME, .tseg1_min = 2, /* Time segment 1 = prop_seg + phase_seg1 */ @@ -1275,7 +1328,7 @@ static int m_can_chip_config(struct net_device *dev) /* Disable unused interrupts */ interrupts &= ~(IR_ARA | IR_ELO | IR_DRX | IR_TEFF | IR_TEFW | IR_TFE | IR_TCF | IR_HPM | IR_RF1F | IR_RF1W | IR_RF1N | - IR_RF0F | IR_RF0W); + IR_RF0F); m_can_config_endisable(cdev, true); @@ -1319,6 +1372,7 @@ static int m_can_chip_config(struct net_device *dev) /* rx fifo configuration, blocking mode, fifo size 1 */ m_can_write(cdev, M_CAN_RXF0C, + FIELD_PREP(RXFC_FWM_MASK, cdev->rx_max_coalesced_frames_irq) | FIELD_PREP(RXFC_FS_MASK, cdev->mcfg[MRAM_RXF0].num) | cdev->mcfg[MRAM_RXF0].off); @@ -1377,7 +1431,7 @@ static int m_can_chip_config(struct net_device *dev) else interrupts &= ~(IR_ERR_LEC_31X); } - m_can_write(cdev, M_CAN_IE, interrupts); + m_can_interrupt_enable(cdev, interrupts); /* route all interrupts to INT0 */ m_can_write(cdev, M_CAN_ILS, ILS_ALL_INT0); @@ -2041,6 +2095,9 @@ int m_can_class_register(struct m_can_classdev *cdev) of_can_transceiver(cdev->net); + hrtimer_init(&cdev->irq_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + cdev->irq_timer.function = m_can_irq_timer; + dev_info(cdev->dev, "%s device registered (irq=%d, version=%d)\n", KBUILD_MODNAME, cdev->net->irq, cdev->version); diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index a839dc71dc9b..c59099d3f5b9 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -84,6 +84,8 @@ struct m_can_classdev { struct sk_buff *tx_skb; struct phy *transceiver; + struct hrtimer irq_timer; + struct m_can_ops *ops; int version; @@ -92,6 +94,11 @@ struct m_can_classdev { int pm_clock_support; int is_peripheral; + // Cached M_CAN_IE register content + u32 active_interrupts; + u32 rx_max_coalesced_frames_irq; + u32 rx_coalesce_usecs_irq; + struct mram_cfg mcfg[MRAM_CFG_NUM]; }; From patchwork Wed Mar 15 11:05:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70131 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2262142wrd; Wed, 15 Mar 2023 04:08:43 -0700 (PDT) X-Google-Smtp-Source: AK7set+a13MWaZ0mz+SGT6OpPHb0tqLw5Yu75iDsWDtLfgvVG8dtMYr1jPqOS/o8J4xcmYq7XZXS X-Received: by 2002:a62:64d4:0:b0:623:81d7:f65f with SMTP id y203-20020a6264d4000000b0062381d7f65fmr10890858pfb.17.1678878523495; Wed, 15 Mar 2023 04:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878523; cv=none; d=google.com; s=arc-20160816; b=KNQzQPTf0ykWNkYWOz1O+XRse7sFXLP6CBkkB5d9PNAX7azt8I7zItzHOTBjjLhkd5 oMReJMxQa+3TWh7xCUquQJ21mizLsGBtnMGmOdOh43NlNcVq6wzXGCoUNl3i7PVvODAS 8PrPFZZMvkMDJCtFyEW5gtQXisLykVv8/gevoW8jscuvptDqvedPc8oOGjkE6sMVreWa FYyH/tB8Rn3mfgRASQ/WoOiXN402rhuQ+sRUDJQmaOVErGr791MULWiWiVUiyKjSgl0l 2daVehVzZF8kwlCXtEEQSUphsW9NcwDWnqvJkPyn0rDDmrIZSQYiVXyAGGs1no9JnKy8 xi/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OHW+8pE2A5c2VoqM9vU7QUWbsPA/ggSN3rae/Dk0G5A=; b=RzIM0tW9jQ8dEHOYp39DHhqriIwYgKQmyvtf2VL05lTFS2U5yN3rVY0FbWlmBWmYE/ wQwH+CEti5/lwZx/kczSyCh0o+Mc25CEz/njbgPv4nCZVhoV5BE+0VCKPVrp5u2rk1RO ZFUAyGJtBvvNXWGQUXb4zukO9ncF6a/2JcuEChpxtcUdLWE/HYKOoawGEkuXq46rWvhc 3KnGoXrM/2PFre/P1yn/UXZKHx5ViXixlai/OorKdDdK8vW2f6F8Z2G9L1Q1CoTbLZj2 oVSebSSvwsEAmoS38eoOOeb9yoAAyBrj9AOHoy0emQZvl5p/Z5byygwLicgSVndKyKs2 YpOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=H5FZwJ1J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y28-20020aa79e1c000000b00622fdc3b442si4923577pfq.144.2023.03.15.04.08.27; Wed, 15 Mar 2023 04:08:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=H5FZwJ1J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231859AbjCOLHb (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbjCOLGm (ORCPT ); Wed, 15 Mar 2023 07:06:42 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BC37856B4 for ; Wed, 15 Mar 2023 04:06:33 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id m35so2734555wms.4 for ; Wed, 15 Mar 2023 04:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OHW+8pE2A5c2VoqM9vU7QUWbsPA/ggSN3rae/Dk0G5A=; b=H5FZwJ1JMuEvd7SN/LBWH2Q/LxGpSvzyVzzGIrLSQlkQzv2tWUjyq+ZdLNVLuFCMm6 f7acADBRMLfEwb1nfb1QgC151ryK74lxPxvBkGvzMJZGCKu3THq1CubBj50iQX5PiScX UlyLGiLeXu7fcI8xjgCI5REMl9FIA9ItG+NBjDDtBjV/3lZxYR5DbvJHa8dqjSwXurlL O/mINTSadJtNso10aO/FVntmwgS/AX6szF5HpPpzUdJQ3xwv3H6VsjC4e14c8lsfBfqp mdo/836BKqVGQF7MecURrwQn5KkkoYzGaPikslaZgSrzcYpz/6EiWdQpNFkE1ypkt4GP /xPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OHW+8pE2A5c2VoqM9vU7QUWbsPA/ggSN3rae/Dk0G5A=; b=sP/9vJp25WqtUwaxDP/ybF/VJFhhTF3K2umHS91Q/o6zOPg0aRGBrbQoI8ncqcBnaI 0Emtw/ulELEdw9QIx/0v1HMWt214rCcSVB/e7rSs6DuhcWG5Mz0/wCCz1kCofKymK/o0 dvUmdUGYmN8zlZY58nq9tGVmrktSGEVLfm1Nl4a9JxpmXtlloxv6t2bTSETvpAg0iAz4 n18mJQENMMgq3pjl7E9Q6N8DkWhEfLvnCmsxWPAAMqIoiAcOSeO1rCOuJR+84LBwCdPF 2rEdZJHYa7vMiAozkaZeddo0p+QHXJiUhy5DEItIuZFMesCYMKRvF4T6qSFGA54If2vz leZQ== X-Gm-Message-State: AO0yUKWAAKxi/TI3u31S+kbwNgE+UAm1TdZtOEAXij0HaeioPpqC2b2l 4DiYs+HtuKpCeoduAp0p6+vrLQ== X-Received: by 2002:a05:600c:4f42:b0:3eb:98aa:54cd with SMTP id m2-20020a05600c4f4200b003eb98aa54cdmr16940364wmq.17.1678878391927; Wed, 15 Mar 2023 04:06:31 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:31 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 08/16] can: m_can: Implement transmit coalescing Date: Wed, 15 Mar 2023 12:05:38 +0100 Message-Id: <20230315110546.2518305-9-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431726611513857?= X-GMAIL-MSGID: =?utf-8?q?1760431726611513857?= Extend the coalescing implementation for transmits. In normal mode the chip raises an interrupt for every finished transmit. This implementation switches to coalescing mode as soon as an interrupt handled a transmit. For coalescing the watermark level interrupt is used to interrupt exactly after x frames were sent. It switches back into normal mode once there was an interrupt with no finished transmit and the timer being inactive. The timer is shared with receive coalescing. The time for receive and transmit coalescing timers have to be the same for that to work. The benefit is to have only a single running timer. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 33 ++++++++++++++++++++------------- drivers/net/can/m_can/m_can.h | 3 +++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index e7dc083e32e4..94c962ac6992 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -255,6 +255,7 @@ enum m_can_reg { #define TXESC_TBDS_64B 0x7 /* Tx Event FIFO Configuration (TXEFC) */ +#define TXEFC_EFWM_MASK GENMASK(29, 24) #define TXEFC_EFS_MASK GENMASK(21, 16) /* Tx Event FIFO Status (TXEFS) */ @@ -1080,7 +1081,7 @@ static void m_can_interrupt_enable(struct m_can_classdev *cdev, u32 interrupts) static void m_can_coalescing_disable(struct m_can_classdev *cdev) { - u32 new_interrupts = cdev->active_interrupts | IR_RF0N; + u32 new_interrupts = cdev->active_interrupts | IR_RF0N | IR_TEFN; hrtimer_cancel(&cdev->irq_timer); m_can_interrupt_enable(cdev, new_interrupts); @@ -1089,21 +1090,26 @@ static void m_can_coalescing_disable(struct m_can_classdev *cdev) static void m_can_coalescing_update(struct m_can_classdev *cdev, u32 ir) { u32 new_interrupts = cdev->active_interrupts; - bool enable_timer = false; + bool enable_rx_timer = false; + bool enable_tx_timer = false; if (cdev->rx_coalesce_usecs_irq > 0 && (ir & (IR_RF0N | IR_RF0W))) { - enable_timer = true; + enable_rx_timer = true; new_interrupts &= ~IR_RF0N; - } else if (!hrtimer_active(&cdev->irq_timer)) { - new_interrupts |= IR_RF0N; } + if (cdev->tx_coalesce_usecs_irq > 0 && (ir & (IR_TEFN | IR_TEFW))) { + enable_tx_timer = true; + new_interrupts &= ~IR_TEFN; + } + if (!enable_rx_timer && !hrtimer_active(&cdev->irq_timer)) + new_interrupts |= IR_RF0N; + if (!enable_tx_timer && !hrtimer_active(&cdev->irq_timer)) + new_interrupts |= IR_TEFN; m_can_interrupt_enable(cdev, new_interrupts); - if (enable_timer) { - hrtimer_start(&cdev->irq_timer, - ns_to_ktime(cdev->rx_coalesce_usecs_irq * NSEC_PER_USEC), + if (enable_rx_timer | enable_tx_timer) + hrtimer_start(&cdev->irq_timer, cdev->irq_timer_wait, HRTIMER_MODE_REL); - } } static irqreturn_t m_can_isr(int irq, void *dev_id) @@ -1158,7 +1164,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) netif_wake_queue(dev); } } else { - if (ir & IR_TEFN) { + if (ir & (IR_TEFN | IR_TEFW)) { /* New TX FIFO Element arrived */ if (m_can_echo_tx_event(dev) != 0) goto out_fail; @@ -1326,9 +1332,8 @@ static int m_can_chip_config(struct net_device *dev) } /* Disable unused interrupts */ - interrupts &= ~(IR_ARA | IR_ELO | IR_DRX | IR_TEFF | IR_TEFW | IR_TFE | - IR_TCF | IR_HPM | IR_RF1F | IR_RF1W | IR_RF1N | - IR_RF0F); + interrupts &= ~(IR_ARA | IR_ELO | IR_DRX | IR_TEFF | IR_TFE | IR_TCF | + IR_HPM | IR_RF1F | IR_RF1W | IR_RF1N | IR_RF0F); m_can_config_endisable(cdev, true); @@ -1365,6 +1370,8 @@ static int m_can_chip_config(struct net_device *dev) } else { /* Full TX Event FIFO is used */ m_can_write(cdev, M_CAN_TXEFC, + FIELD_PREP(TXEFC_EFWM_MASK, + cdev->tx_max_coalesced_frames_irq) | FIELD_PREP(TXEFC_EFS_MASK, cdev->mcfg[MRAM_TXE].num) | cdev->mcfg[MRAM_TXE].off); diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index c59099d3f5b9..d0c21eddb6ec 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -85,6 +85,7 @@ struct m_can_classdev { struct phy *transceiver; struct hrtimer irq_timer; + ktime_t irq_timer_wait; struct m_can_ops *ops; @@ -98,6 +99,8 @@ struct m_can_classdev { u32 active_interrupts; u32 rx_max_coalesced_frames_irq; u32 rx_coalesce_usecs_irq; + u32 tx_max_coalesced_frames_irq; + u32 tx_coalesce_usecs_irq; struct mram_cfg mcfg[MRAM_CFG_NUM]; }; From patchwork Wed Mar 15 11:05:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70126 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2261981wrd; Wed, 15 Mar 2023 04:08:28 -0700 (PDT) X-Google-Smtp-Source: AK7set95icEyQZRg3EcoQDz/sesue3uXQQdG4lcug2yap04CVJSl+0ehCgBKVnHNpu4aTkldc7uD X-Received: by 2002:a17:90a:31c:b0:233:f394:d83 with SMTP id 28-20020a17090a031c00b00233f3940d83mr38870510pje.48.1678878508392; Wed, 15 Mar 2023 04:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878508; cv=none; d=google.com; s=arc-20160816; b=rIiDKDC0IanTrElz7OPZylWq9KcFw8+52zaZl5rCu3s9ejOGUwjB8AfqmoBq8c5NxT 9F2Y+B/YB1RRAhDI0UDTOY5NahYlWBpwE+vmtxxaOPQKBGO/JOmjTPb3Ur74CQs9Au3W S16hnHULZBZb3PDuozs3VvPztYJQj+kqoBZ3WBPCQZX6IUbK/Shq0GnHRM1xCMDA0Yh+ zZvCCXOBYT+pgQ1Zb4Xx1khRdlVyuj/xo990wFpqvgKmqsfc+Uucud/5JdCBZjgx3P9U A5SLsxIeksyArLVs8gXDKsg2kwRJuhyW9qPcSrOQVhsyUVFzH5X8GItEgbM+QtK43qHM fr5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JK3QCAzV2uxsgFdaubQ9QvC1c5aZ/o2EHMkQeIZH7RA=; b=ZMFSDTCtmlvytyi39ohA1DQRe/iS+4CWxKVVrrtXXrc6wSmk3QT9Vx4yIgqgMilejl ziEEUU1G+zWNCv7g5FUSTwN7yyit5M39ZJBHdWYFPHmovmDSVzThTKQip4FYyLO1oxpD 4IEdq6ufsm36ktsHc9DgLqeQbjv6fEd+WO3vmmWBkmdRn8DbGtX6ZRgJoiO8jg7hxu32 pfdm02noCjbxRhTe1VNcLbOQuDDUpId7LI1KX/GD9LLlGQDl4El0uVab1WTgw9CWcO1R i2DQXj74QpoAM5XNqJ3/7XgbCntxm5LpU4a4ofj3Jv726bVEfJ506qCD/D2xB9ah/mk5 zc7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=lYYgm1cN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z128-20020a636586000000b00502e7406695si4757315pgb.316.2023.03.15.04.08.12; Wed, 15 Mar 2023 04:08:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=lYYgm1cN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231976AbjCOLHP (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbjCOLGn (ORCPT ); Wed, 15 Mar 2023 07:06:43 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5187E85A48 for ; Wed, 15 Mar 2023 04:06:34 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id ay8so7017762wmb.1 for ; Wed, 15 Mar 2023 04:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JK3QCAzV2uxsgFdaubQ9QvC1c5aZ/o2EHMkQeIZH7RA=; b=lYYgm1cNWYtBWM9/MP6pOb3usNz4beGBqUXvyznePJP2TBOG5eGAexBzwQFP5OG4Wi TLTAhPPo4TeaNcrcRyhxqkbiqcPUkki0sHYsevJL0a3o1bUzDUD+5kn/hhYjIEYOHbUQ cs1SMmShHlET6PpHWudYdrNXJ4/TerAH8UTd1oPW2GFsaCfZCyfwrF0SYztqD+8Tb0u6 N40pDsV8/jdNalHUmPZPcrlQ2W80zBYzkXri2kC9mxUrrgmjjbLB2/zYlN3i1bxFLPf8 l0m9c0FBmZYfC3VE9Bm7l9BVMsZAh9kMj7rjGHi2J1jMianx5izwJhgSgaqpmVR/YW92 LBPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JK3QCAzV2uxsgFdaubQ9QvC1c5aZ/o2EHMkQeIZH7RA=; b=B0R4l5mJ02FBOrsOTeUN9qnTr5LhytUOZG2Rq77J6Ktz28/5h4wgzhEFQyo3s48xko IUplV6pIfOnpY/vhm/NFnxsHmTh9gFqxlul4fuqTXbaUgGBBItj5CyMivi2R9IN867dM LV70vNhdBNXrVI2f8nVh1M9I/JpPvtWSUvp58Ah3qiHwTGVzFyRO4YgqLWxezX7yEqSf Z3EZtlFNqrE0Zbmf+vEJarYzQQghjdlM5hreo0MrG6VQMr4d9J3gCG1buxcz8PZYyQuK t9Gmqb7eck6VpUKy5jBRyuE1hT9rtyJR1ROZuC+zs5ejBdi1hfYe04oDypsmqAoUsIty Habw== X-Gm-Message-State: AO0yUKWlIJvM9MPwTNowPoqltVzviS0N8vCLxqd071HCjg6wawoYfQrm FAXTsPcpZNbGxyiJtk1OPWhbOg== X-Received: by 2002:a05:600c:4751:b0:3ea:f0d6:5d36 with SMTP id w17-20020a05600c475100b003eaf0d65d36mr17547733wmo.29.1678878392795; Wed, 15 Mar 2023 04:06:32 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:32 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 09/16] can: m_can: Add rx coalescing ethtool support Date: Wed, 15 Mar 2023 12:05:39 +0100 Message-Id: <20230315110546.2518305-10-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431710488410178?= X-GMAIL-MSGID: =?utf-8?q?1760431710488410178?= Add the possibility to set coalescing parameters with ethtool. rx-frames-irq and rx-usecs-irq can only be set and unset together as the implemented mechanism would not work otherwise. rx-frames-irq can't be greater than the RX FIFO size. Also all values can only be changed if the chip is not active. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 94c962ac6992..7f8decfae81e 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1936,8 +1936,54 @@ static const struct net_device_ops m_can_netdev_ops = { .ndo_change_mtu = can_change_mtu, }; +static int m_can_get_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec, + struct kernel_ethtool_coalesce *kec, + struct netlink_ext_ack *ext_ack) +{ + struct m_can_classdev *cdev = netdev_priv(dev); + + ec->rx_max_coalesced_frames_irq = cdev->rx_max_coalesced_frames_irq; + ec->rx_coalesce_usecs_irq = cdev->rx_coalesce_usecs_irq; + + return 0; +} + +static int m_can_set_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec, + struct kernel_ethtool_coalesce *kec, + struct netlink_ext_ack *ext_ack) +{ + struct m_can_classdev *cdev = netdev_priv(dev); + + if (cdev->can.state != CAN_STATE_STOPPED) { + netdev_err(dev, "Device is in use, please shut it down first\n"); + return -EBUSY; + } + + if (ec->rx_max_coalesced_frames_irq > cdev->mcfg[MRAM_RXF0].num) { + netdev_err(dev, "rx-frames-irq %u greater than the RX FIFO %u\n", + ec->rx_max_coalesced_frames_irq, + cdev->mcfg[MRAM_RXF0].num); + return -EINVAL; + } + if ((ec->rx_max_coalesced_frames_irq == 0) != (ec->rx_coalesce_usecs_irq == 0)) { + netdev_err(dev, "rx-frames-irq and rx-usecs-irq can only be set together\n"); + return -EINVAL; + } + + cdev->rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq; + cdev->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq; + + return 0; +} + static const struct ethtool_ops m_can_ethtool_ops = { + .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ | + ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ, .get_ts_info = ethtool_op_get_ts_info, + .get_coalesce = m_can_get_coalesce, + .set_coalesce = m_can_set_coalesce, }; static int register_m_can_dev(struct net_device *dev) From patchwork Wed Mar 15 11:05:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70144 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2267964wrd; Wed, 15 Mar 2023 04:22:13 -0700 (PDT) X-Google-Smtp-Source: AK7set84Px5HeTtkuaP+7dvz37nYwb6f2mGVNqmszUSSI7rrw59cnaSZ0ygi62PUKOhSANVNW+HG X-Received: by 2002:a62:18d5:0:b0:622:5ccd:85e2 with SMTP id 204-20020a6218d5000000b006225ccd85e2mr12594867pfy.25.1678879333361; Wed, 15 Mar 2023 04:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678879333; cv=none; d=google.com; s=arc-20160816; b=pHzJXISd8JA30SkpYJE0M5V9wbKWYkG/wsn0egrT8POE8IdGVzhyOEeULaTRt7Aw3v zXA32euDrZ2MaNnzrDBV1UBeOnq+b/KpywlXqzoM4ai4p8r8p/UmhDhl8HAHWX2BvaMc xtadeFZGbV4twdmw1aK0UWjK5fWilL8lcmfT540ofF4P3imwM7xnM3fLFhQf8PAhTpW3 lC+0LUPlFbM+i4rEiQHDcgBgXdmnsn/OtUtDidmGa92EXEms/1RCz1ryG7tUrgb4HA2q 18elkVUeIGDv6twRSWh/XQ8ZY25GxnWMxDmH3Kcsgy7kWWBfc+8p141Yk/6cG6qMM9g0 yrpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pN8ZptlzgPfmzxJWQLQrj0zNzAhVKIv7Ben+aSmHqb0=; b=McSnssTr2q8ct1LsmH8LO4dEe14hHCoYWlaYIEw51SsTzHbAGSrKuF42xS6Fpm/RT2 xqZ2UnhhYoWovtKSgiUhsCJb36aY/xL+sQ5iEy1xa1JYPX0jGTPhPeXyrFf3XlN/3EPX RUew8xJwi1x4vw8GkPKgQkjpN9sS+sCcE6gaurPiA9N6ov7SD9RYcEfkKXQ79OMZdaej HSWHkAEY0YCzp8DgbIXNllUbHleTSeYQwd7JJixhReXPE4eAkVLQOT8p87POaV/pS5Io PMdZX5E4nB76ylflBFIFO1+dMpjDTMnei/bvx+Pc7rD7gOraaqpDe2rzmQRU9/NG8Xkv Nrkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=ghvNo6x9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f189-20020a6251c6000000b006257e7e5bbesi2945838pfb.325.2023.03.15.04.21.58; Wed, 15 Mar 2023 04:22:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=ghvNo6x9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231523AbjCOLHT (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbjCOLGn (ORCPT ); Wed, 15 Mar 2023 07:06:43 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED32F80924 for ; Wed, 15 Mar 2023 04:06:34 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id p16so12270317wmq.5 for ; Wed, 15 Mar 2023 04:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pN8ZptlzgPfmzxJWQLQrj0zNzAhVKIv7Ben+aSmHqb0=; b=ghvNo6x9DSvQCMX3QL5tHHUGyph0cRLvLNK26q2eC/ZTLdyFWDhxBOMvlYqLeegeeA nFXmAQbGu96dtj9X/Q65XaAtwlC7TLLCzfy8jXPSNo7eceCkL1dEbAyqjqTkXZOyvTCy aMAtptSRDf5Y4zfb3k7xKgca5BqLb4GciPe1cd6BRIiwYzuepLlGGqutGupOLkVk1a6t nHjb1aZamEnOiS1GYsj0YSDaEdNWJ28CgFhSsc+VXLDaGW5Dve1+yr3PdRKOu6VA8Cv1 UH0vwWwVw1STSTOP6SXTVWrdyktij1UVGHOR2/hEdW564SWmpM0JnxyNa7B/HXqw4acy t3qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pN8ZptlzgPfmzxJWQLQrj0zNzAhVKIv7Ben+aSmHqb0=; b=2TPdk9FltfJuRoZ910SpRmup2/xqJoCrrWcrsxrgddOk/KZfZfV4IHfcPKgFf3qFVa 8KTiqqNwYJd4OLyO6DWHdjiN3oFkcCDBvrmJQ9c+Ax0G/X1NEUDS2Zb4jX0s+vx/dUfm dVQUO2mBW+eaq6lTP7TBNijkW2RDgGi2b3Y7fnVUZy/rIj0DO+YQcjIGj/RzIiqjzh5m sTB96yzoF6JlMvdxdOZMIyO2We7NLuDEJ65jM8XHjzr8XKjUrJoVhU7iAr4qwzrP11vZ rtEKExWvPyAO84sBa8Io08b9FxATzlCkJZlVxPd6VxKNxwrbTvmBTnYDPTfi9C2FS6nC M3uQ== X-Gm-Message-State: AO0yUKXWin28J6k5oN3l4/KdEvhE5HFetiwtJ5mA4on7+ZpE6MHyIFJx qNTsk12ULjqapzgQqK+qkOe0Fw== X-Received: by 2002:a05:600c:a48:b0:3ed:245f:97a with SMTP id c8-20020a05600c0a4800b003ed245f097amr9194314wmq.19.1678878393594; Wed, 15 Mar 2023 04:06:33 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:33 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 10/16] can: m_can: Add tx coalescing ethtool support Date: Wed, 15 Mar 2023 12:05:40 +0100 Message-Id: <20230315110546.2518305-11-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760432575421220509?= X-GMAIL-MSGID: =?utf-8?q?1760432575421220509?= Add get/set functions for ethtool coalescing. tx-frames-irq and tx-usecs-irq can only be set/unset together. tx-frames-irq needs to be less than TXE and TXB. As rx and tx share the same timer, rx-usecs-irq and tx-usecs-irq can be enabled/disabled individually but they need to have the same value if enabled. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 7f8decfae81e..4e794166664a 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1945,6 +1945,8 @@ static int m_can_get_coalesce(struct net_device *dev, ec->rx_max_coalesced_frames_irq = cdev->rx_max_coalesced_frames_irq; ec->rx_coalesce_usecs_irq = cdev->rx_coalesce_usecs_irq; + ec->tx_max_coalesced_frames_irq = cdev->tx_max_coalesced_frames_irq; + ec->tx_coalesce_usecs_irq = cdev->tx_coalesce_usecs_irq; return 0; } @@ -1971,16 +1973,50 @@ static int m_can_set_coalesce(struct net_device *dev, netdev_err(dev, "rx-frames-irq and rx-usecs-irq can only be set together\n"); return -EINVAL; } + if (ec->tx_max_coalesced_frames_irq > cdev->mcfg[MRAM_TXE].num) { + netdev_err(dev, "tx-frames-irq %u greater than the TX event FIFO %u\n", + ec->tx_max_coalesced_frames_irq, + cdev->mcfg[MRAM_TXE].num); + return -EINVAL; + } + if (ec->tx_max_coalesced_frames_irq > cdev->mcfg[MRAM_TXB].num) { + netdev_err(dev, "tx-frames-irq %u greater than the TX FIFO %u\n", + ec->tx_max_coalesced_frames_irq, + cdev->mcfg[MRAM_TXB].num); + return -EINVAL; + } + if ((ec->tx_max_coalesced_frames_irq == 0) != (ec->tx_coalesce_usecs_irq == 0)) { + netdev_err(dev, "tx-frames-irq and tx-usecs-irq can only be set together\n"); + return -EINVAL; + } + if (ec->rx_coalesce_usecs_irq != 0 && ec->tx_coalesce_usecs_irq != 0 && + ec->rx_coalesce_usecs_irq != ec->tx_coalesce_usecs_irq) { + netdev_err(dev, "rx-usecs-irq %u needs to be equal to tx-usecs-irq %u if both are enabled\n", + ec->rx_coalesce_usecs_irq, + ec->tx_coalesce_usecs_irq); + return -EINVAL; + } cdev->rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq; cdev->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq; + cdev->tx_max_coalesced_frames_irq = ec->tx_max_coalesced_frames_irq; + cdev->tx_coalesce_usecs_irq = ec->tx_coalesce_usecs_irq; + + if (cdev->rx_coalesce_usecs_irq) + cdev->irq_timer_wait = + ns_to_ktime(cdev->rx_coalesce_usecs_irq * NSEC_PER_USEC); + else + cdev->irq_timer_wait = + ns_to_ktime(cdev->tx_coalesce_usecs_irq * NSEC_PER_USEC); return 0; } static const struct ethtool_ops m_can_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ | - ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ, + ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | + ETHTOOL_COALESCE_TX_USECS_IRQ | + ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ, .get_ts_info = ethtool_op_get_ts_info, .get_coalesce = m_can_get_coalesce, .set_coalesce = m_can_set_coalesce, From patchwork Wed Mar 15 11:05:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70130 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2262051wrd; Wed, 15 Mar 2023 04:08:34 -0700 (PDT) X-Google-Smtp-Source: AK7set/12W1MIBbtJaT/R4y5vwXSbG9Z/9ZDCdT4wxXkGZGaTwzXWsHSE9vlBIA2sql32taktwTz X-Received: by 2002:a17:90b:3b4b:b0:234:19a1:8690 with SMTP id ot11-20020a17090b3b4b00b0023419a18690mr41510777pjb.26.1678878514622; Wed, 15 Mar 2023 04:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878514; cv=none; d=google.com; s=arc-20160816; b=aYDp+gy8rjRn1CiaigdD9IDxu3LsT/y824BPpxwY981EDg5QAe+YHRtVunHd2OGuKE dULibKEh7ec/4h90gknAqXQ16jqwlf0wQgHZVPs69AUcU2zKM3KcxOyEOcXCAjflz52s Ld35JZ6U33NSpeJPVx3KIg5uaiFVe2IcpCqHgvxr9vbt8F1DLQt7PmArOcpT9gayiGK8 lSCnYHSX3U+zHZjDiosut7YbQYKlJwgaTjMN7X0GmzQJmiklQoLTdkYoF6nr1BAXFwBl UdEclMhbvh6shQLLIV08qDZlcH1tO7xZ4K83lQ/NxuUmbdh1xrLeDdM8MIWATnnf9jiQ Wq0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+ZThZMgUyn2/5ZBEZWr8O3JON+m0nr5Da03HtR+hrv4=; b=A4vL5zUjnMtq72yEfAvCvcafGqqGxJpJMuaPQdNwHJ83MGyY7mMPD6H/P63OHCQOfx xzGaDkbhenFtAtbLqWAg7QmYMa6d/UlY9TqeO+baVIwLAavlkFgvWp6o83H4PSsYNjkK zLauwDdZRhnlYSm9OR/AY9VNGgD5hWZ8BYkUr/IlnT/yRxxKF1vn4jYW0cHRbBoB4Bg7 wxwzHTOzI557O68Rugi25GuVYnAe7XZQgKWLZ90mwMbo3wCMvpx0OAcyGsRzksEK5W8l IY9bpqG5ZpVMDSwbnJGqJuGdIgqT7eB2kIx106K40z892WmPY1oaeiyB1p0St/8O1XGO XegA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=1jJdQZBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a17090a6b4500b00233d10c93b9si1340470pjl.179.2023.03.15.04.08.21; Wed, 15 Mar 2023 04:08:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=1jJdQZBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231700AbjCOLH2 (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231717AbjCOLGo (ORCPT ); Wed, 15 Mar 2023 07:06:44 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C23C085A6E for ; Wed, 15 Mar 2023 04:06:35 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id p13-20020a05600c358d00b003ed346d4522so677060wmq.2 for ; Wed, 15 Mar 2023 04:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+ZThZMgUyn2/5ZBEZWr8O3JON+m0nr5Da03HtR+hrv4=; b=1jJdQZBohfY1QzhcZD2so0Dyo46RuqJL5F0a2JAIJmVw9FKiwNSCajBvzLErI/1v4J HUWjs90pw38xxhs5Dla/ic9E1QRCaovsRxKxkf7kKfeO5qE/O8h1R3nkbdJFv61ZaEqd Zb9lMQL3RLUuauMISsE8ruR+WuZWJV7Uu9PXyOi9er+qIQWWJ1K3VjVp9W8P4dBKCQ1Q GtAgjTQs7kmcDpmudifb6FmqcorCzYCdMvABjk1ZPygPtXcd2prhgWwzRTMSSHb+lysq J0GT4ToJcATAXE+CGdzBsoCKJTfNng6cYc57GMXImCKFEIY8whIVYP7A4rAYfZjDLIuQ IoTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+ZThZMgUyn2/5ZBEZWr8O3JON+m0nr5Da03HtR+hrv4=; b=ZgbBjCe0o4/JcLQGn2pYI4mAmFwWPbnfnwztDiORLQ8FfWYlzzxAoVO8zNGbSkyp63 PGFwM/C0YFEOSYcPdrLwwLpDpABE6ZfJUvNfOP7EaFae1OxWaVaoNfZRmaCUO/ljDkqf lk0G0rq9xWxEh/8rZZnzaOTpvVp9oYLZJ73yisC40khbnCX436qtne/Shek1yIAJL3aR AxcNSv7MuZvNz+CJwv17PhERg9lYfdVwpNJ9uX6v2iG1THYqqoLkOZEBQOLP7CnL90Ig aOkbZyxK7AinD+uPeU3JLPIrjJC+0YZDxRGmlbvWeLgVzZYyXsnuNGcyvqnMR9tJwSDp 1WMQ== X-Gm-Message-State: AO0yUKXwXLuRv47NIOHam74cifoWpV+YQfjAioH8WovfDnQ+p6bF5b31 ggP6qXYY+QYSBpY3VC+Fm2gUY43oiMapLDPlk+s= X-Received: by 2002:a05:600c:190c:b0:3eb:38e6:f65d with SMTP id j12-20020a05600c190c00b003eb38e6f65dmr17284068wmq.11.1678878394397; Wed, 15 Mar 2023 04:06:34 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:34 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 11/16] can: m_can: Cache tx putidx Date: Wed, 15 Mar 2023 12:05:41 +0100 Message-Id: <20230315110546.2518305-12-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431717075636708?= X-GMAIL-MSGID: =?utf-8?q?1760431717075636708?= m_can_tx_handler is the only place where data is written to the tx fifo. We can calculate the putidx in the driver code here to avoid the dependency on the txfqs register. Signed-off-by: Markus Schneider-Pargmann Signed-off-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 8 +++++++- drivers/net/can/m_can/m_can.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 4e794166664a..d5bcce948d2c 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1475,6 +1475,10 @@ static int m_can_start(struct net_device *dev) m_can_enable_all_interrupts(cdev); + if (cdev->version > 30) + cdev->tx_fifo_putidx = FIELD_GET(TXFQS_TFQPI_MASK, + m_can_read(cdev, M_CAN_TXFQS)); + return 0; } @@ -1765,7 +1769,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) } /* get put index for frame */ - putidx = FIELD_GET(TXFQS_TFQPI_MASK, txfqs); + putidx = cdev->tx_fifo_putidx; /* Construct DLC Field, with CAN-FD configuration. * Use the put index of the fifo as the message marker, @@ -1798,6 +1802,8 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) /* Enable TX FIFO element to start transfer */ m_can_write(cdev, M_CAN_TXBAR, (1 << putidx)); + cdev->tx_fifo_putidx = (++cdev->tx_fifo_putidx >= cdev->can.echo_skb_max ? + 0 : cdev->tx_fifo_putidx); /* stop network queue if fifo full */ if (m_can_tx_fifo_full(cdev) || diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index d0c21eddb6ec..548ae908ac4e 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -102,6 +102,9 @@ struct m_can_classdev { u32 tx_max_coalesced_frames_irq; u32 tx_coalesce_usecs_irq; + // Store this internally to avoid fetch delays on peripheral chips + int tx_fifo_putidx; + struct mram_cfg mcfg[MRAM_CFG_NUM]; }; From patchwork Wed Mar 15 11:05:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70128 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2262018wrd; Wed, 15 Mar 2023 04:08:32 -0700 (PDT) X-Google-Smtp-Source: AK7set9prFgLOB1YISdwDC4Yoo92POT65fvOutWA/szCi3LSVTCwykz5R1+tl4VuPl4cz3irCd1c X-Received: by 2002:a05:6a21:9998:b0:d3:73be:3ea2 with SMTP id ve24-20020a056a21999800b000d373be3ea2mr18794938pzb.36.1678878511805; Wed, 15 Mar 2023 04:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878511; cv=none; d=google.com; s=arc-20160816; b=ClgeTvxTWwbWZbBLqSmeJ9dCszLAIwTLqGevm30zj3GR46jUr5FS55eY5PIokOxaZJ 9hpfm4dcZFAoYkGY86YspQbPTMqp+V2aLJmhMVwMmaQpFDGcMLEjRUzax3U/hroO2Fr3 ABcpFWMixWaIUv9NaRG5FyiU0f2/xsYT8XvCms9vyMhbi2JuCsiMnaIvKkphKeenEK3m 65tM74+zpFPqtUHQAXAJhSOLJVo+gyIHYclRjbG1L7R1oJNJf8DRRtT4LIFdpdPh85Qq Y84S5j0BfjvdfrBtuF3JDG7x29R2grAelrsiFMqaWBw3KamdlZgaNxst1F4RWjkbyRKo GUhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IYMN+s7YTSsz1VMif6thfJovaMveV9x3p4QG54JzCXU=; b=CdpraIbl+jMblNvDU0ERW97oFakzoCjfpY0gGZDkxfo2xCCnClHufP+rhlb3cdRxGt Mb8F5sVRySmG0wzYfX06RMQJTTXO/1dHxaaPY13QTE6f5ay97Ss9tZhQpcALNZDrRZ4X 1OdhYn2s0M/DY6lXRMNfJTav3miq1QWZ4tVk9fd0RKigEWyixsl5xLdc37GTSHAfW0HS 76gDY1vatXT+G/sheOIskjSqSjsEzY9elTBu29O/bA/b1tDnpIOVE/l3UdUJfD14ZRNn iOq89p7TANC+S66ePA1LVgWHA2lBbHcrXLIdQsMGsZcxK0quqvuDTUO/ANLcTr1Q16sW FZsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=rNmq3h64; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y15-20020a63494f000000b0050bd14260adsi3156584pgk.235.2023.03.15.04.08.18; Wed, 15 Mar 2023 04:08:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=rNmq3h64; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231820AbjCOLHZ (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231725AbjCOLGo (ORCPT ); Wed, 15 Mar 2023 07:06:44 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E571A85B08 for ; Wed, 15 Mar 2023 04:06:36 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id m35so2734656wms.4 for ; Wed, 15 Mar 2023 04:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IYMN+s7YTSsz1VMif6thfJovaMveV9x3p4QG54JzCXU=; b=rNmq3h644DfBAjchNxOY4W4htOYRcdfHx9c/yK7qpBcqr5sMgGZiy8VNYHY10MBU5Q QNZFKCWFUc0Yn9MeoPr20kiMKGvLc/uDbMQMyYXSW5T4GcHW7AC2bI6XLa4v8LH8Jian ChdXjm2cgt4C1JnuBGE3T0yaNPTWPTkMqc1g+Uj6a9IMsd7sUGtQFc/O76VXkrKM2Zfw NfRsQnv3fB5EyovYKiIbiQN3caTkfxjfhTqE7QIg0gBs5dLcx65rRvqxU/7Sbf0zRGRW iY78OGQHIj5mI4RUeq73TeH/cfw6XhkeTR94pUvPqlchHfSQPqEKQeWdibpTDSeDtaIF +9XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IYMN+s7YTSsz1VMif6thfJovaMveV9x3p4QG54JzCXU=; b=V4ngi1tlXUqqw1fCVn/WsKqk/9Zud45xXbuWtrl7Msmo64ZBiWgzchd4d+qe7qAN/1 z8VClgarUEM4fA4DxzLPbHFU365Qgl7/B4UHO5g/YmE1D+FploJRsCUZtFI/u3C+I6dp LeN2sBdSOyUBlFoJr7H7NHs++YwwXp9sKmi3HZ7QT+d+fGtMmO4MUh3rVbNVnrcE5Us5 uS8GpVkOkcr6RlGdrdQPtKJs4hX4TMAfHQJw84btrfYcFX0PvgvKqLUbZJ1UFpGazhBQ 0uwGFCd+dNa0u9pzkRvjRIbFZQETyx22xWs2NN/Ou0TtH3DR5ULYcrxGzTbydKYU9nQi aodA== X-Gm-Message-State: AO0yUKWb+x0Ze3j11tN+c8hbHwRG9NNsH9eimyRULIyfEQLdNdNtw15E ZWvAKO3kJcBng6c5UXJVZwu34w== X-Received: by 2002:a05:600c:4511:b0:3ed:302f:3a61 with SMTP id t17-20020a05600c451100b003ed302f3a61mr2819927wmo.12.1678878395210; Wed, 15 Mar 2023 04:06:35 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:34 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 12/16] can: m_can: Use the workqueue as queue Date: Wed, 15 Mar 2023 12:05:42 +0100 Message-Id: <20230315110546.2518305-13-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431714381688432?= X-GMAIL-MSGID: =?utf-8?q?1760431714381688432?= The current implementation uses the workqueue for peripheral chips to submit work. Only a single work item is queued and used at any time. To be able to keep more than one transmit in flight at a time, prepare the workqueue to support multiple transmits at the same time. Each work item now has a separate storage for a skb and a pointer to cdev. This assures that each workitem can be processed individually. The workqueue is replaced by an ordered workqueue which makes sure that only a single worker processes the items queued on the workqueue. Also items are ordered by the order they were enqueued. This removes most of the concurrency the workqueue normally offers. It is not necessary for this driver. The cleanup functions have to be adopted a bit to handle this new mechanism. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 109 ++++++++++++++++++++-------------- drivers/net/can/m_can/m_can.h | 12 +++- 2 files changed, 74 insertions(+), 47 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index d5bcce948d2c..27d36bcc094c 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -443,17 +443,16 @@ static void m_can_clean(struct net_device *net) { struct m_can_classdev *cdev = netdev_priv(net); - if (cdev->tx_skb) { - int putidx = 0; + for (int i = 0; i != cdev->tx_fifo_size; ++i) { + if (!cdev->tx_ops[i].skb) + continue; net->stats.tx_errors++; - if (cdev->version > 30) - putidx = FIELD_GET(TXFQS_TFQPI_MASK, - m_can_read(cdev, M_CAN_TXFQS)); - - can_free_echo_skb(cdev->net, putidx, NULL); - cdev->tx_skb = NULL; + cdev->tx_ops[i].skb = NULL; } + + for (int i = 0; i != cdev->can.echo_skb_max; ++i) + can_free_echo_skb(cdev->net, i, NULL); } /* For peripherals, pass skb to rx-offload, which will push skb from @@ -1656,8 +1655,9 @@ static int m_can_close(struct net_device *dev) m_can_clk_stop(cdev); free_irq(dev->irq, dev); + m_can_clean(dev); + if (cdev->is_peripheral) { - cdev->tx_skb = NULL; destroy_workqueue(cdev->tx_wq); cdev->tx_wq = NULL; can_rx_offload_disable(&cdev->offload); @@ -1684,19 +1684,17 @@ static int m_can_next_echo_skb_occupied(struct net_device *dev, int putidx) return !!cdev->can.echo_skb[next_idx]; } -static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) +static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, + struct sk_buff *skb) { - struct canfd_frame *cf = (struct canfd_frame *)cdev->tx_skb->data; + struct canfd_frame *cf = (struct canfd_frame *)skb->data; struct net_device *dev = cdev->net; - struct sk_buff *skb = cdev->tx_skb; struct id_and_dlc fifo_header; u32 cccr, fdflags; u32 txfqs; int err; int putidx; - cdev->tx_skb = NULL; - /* Generate ID field for TX buffer Element */ /* Common to all supported M_CAN versions */ if (cf->can_id & CAN_EFF_FLAG) { @@ -1821,10 +1819,36 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) static void m_can_tx_work_queue(struct work_struct *ws) { - struct m_can_classdev *cdev = container_of(ws, struct m_can_classdev, - tx_work); + struct m_can_tx_op *op = container_of(ws, struct m_can_tx_op, work); + struct m_can_classdev *cdev = op->cdev; + struct sk_buff *skb = op->skb; - m_can_tx_handler(cdev); + op->skb = NULL; + m_can_tx_handler(cdev, skb); +} + +static void m_can_tx_queue_skb(struct m_can_classdev *cdev, struct sk_buff *skb) +{ + cdev->tx_ops[cdev->next_tx_op].skb = skb; + queue_work(cdev->tx_wq, &cdev->tx_ops[cdev->next_tx_op].work); + + ++cdev->next_tx_op; + if (cdev->next_tx_op >= cdev->tx_fifo_size) + cdev->next_tx_op = 0; +} + +static netdev_tx_t m_can_start_peripheral_xmit(struct m_can_classdev *cdev, + struct sk_buff *skb) +{ + if (cdev->can.state == CAN_STATE_BUS_OFF) { + m_can_clean(cdev->net); + return NETDEV_TX_OK; + } + + netif_stop_queue(cdev->net); + m_can_tx_queue_skb(cdev, skb); + + return NETDEV_TX_OK; } static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, @@ -1835,30 +1859,10 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, if (can_dev_dropped_skb(dev, skb)) return NETDEV_TX_OK; - if (cdev->is_peripheral) { - if (cdev->tx_skb) { - netdev_err(dev, "hard_xmit called while tx busy\n"); - return NETDEV_TX_BUSY; - } - - if (cdev->can.state == CAN_STATE_BUS_OFF) { - m_can_clean(dev); - } else { - /* Need to stop the queue to avoid numerous requests - * from being sent. Suggested improvement is to create - * a queueing mechanism that will queue the skbs and - * process them in order. - */ - cdev->tx_skb = skb; - netif_stop_queue(cdev->net); - queue_work(cdev->tx_wq, &cdev->tx_work); - } - } else { - cdev->tx_skb = skb; - return m_can_tx_handler(cdev); - } - - return NETDEV_TX_OK; + if (cdev->is_peripheral) + return m_can_start_peripheral_xmit(cdev, skb); + else + return m_can_tx_handler(cdev, skb); } static int m_can_open(struct net_device *dev) @@ -1886,15 +1890,17 @@ static int m_can_open(struct net_device *dev) /* register interrupt handler */ if (cdev->is_peripheral) { - cdev->tx_skb = NULL; - cdev->tx_wq = alloc_workqueue("mcan_wq", - WQ_FREEZABLE | WQ_MEM_RECLAIM, 0); + cdev->tx_wq = alloc_ordered_workqueue("mcan_wq", + WQ_FREEZABLE | WQ_MEM_RECLAIM); if (!cdev->tx_wq) { err = -ENOMEM; goto out_wq_fail; } - INIT_WORK(&cdev->tx_work, m_can_tx_work_queue); + for (int i = 0; i != cdev->tx_fifo_size; ++i) { + cdev->tx_ops[i].cdev = cdev; + INIT_WORK(&cdev->tx_ops[i].work, m_can_tx_work_queue); + } err = request_threaded_irq(dev->irq, NULL, m_can_isr, IRQF_ONESHOT, @@ -2164,6 +2170,19 @@ int m_can_class_register(struct m_can_classdev *cdev) { int ret; + cdev->tx_fifo_size = max(1, min(cdev->mcfg[MRAM_TXB].num, + cdev->mcfg[MRAM_TXE].num)); + if (cdev->is_peripheral) { + cdev->tx_ops = + devm_kzalloc(cdev->dev, + cdev->tx_fifo_size * sizeof(*cdev->tx_ops), + GFP_KERNEL); + if (!cdev->tx_ops) { + dev_err(cdev->dev, "Failed to allocate tx_ops for workqueue\n"); + return -ENOMEM; + } + } + if (cdev->pm_clock_support) { ret = m_can_clk_start(cdev); if (ret) diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index 548ae908ac4e..2e1a52980a18 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -70,6 +70,12 @@ struct m_can_ops { int (*init)(struct m_can_classdev *cdev); }; +struct m_can_tx_op { + struct m_can_classdev *cdev; + struct work_struct work; + struct sk_buff *skb; +}; + struct m_can_classdev { struct can_priv can; struct can_rx_offload offload; @@ -80,8 +86,6 @@ struct m_can_classdev { struct clk *cclk; struct workqueue_struct *tx_wq; - struct work_struct tx_work; - struct sk_buff *tx_skb; struct phy *transceiver; struct hrtimer irq_timer; @@ -105,6 +109,10 @@ struct m_can_classdev { // Store this internally to avoid fetch delays on peripheral chips int tx_fifo_putidx; + struct m_can_tx_op *tx_ops; + int tx_fifo_size; + int next_tx_op; + struct mram_cfg mcfg[MRAM_CFG_NUM]; }; From patchwork Wed Mar 15 11:05:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70145 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2268154wrd; Wed, 15 Mar 2023 04:22:43 -0700 (PDT) X-Google-Smtp-Source: AK7set9n3xCJk9OwUgFgZT8aWmbIwsDk9j5WATi1blT2PX12kCX6BLHTF1qgcAc6qx1sW5BT3Wkx X-Received: by 2002:a17:902:d486:b0:19c:a866:6a76 with SMTP id c6-20020a170902d48600b0019ca8666a76mr2499038plg.42.1678879363572; Wed, 15 Mar 2023 04:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678879363; cv=none; d=google.com; s=arc-20160816; b=ZRWiGJjLA53XGhQlW6+QzyYJ+TEcoSwKp2jswEHqMD7UNeWPNYVzc+dVZ6NaWVY100 xdU9hvh/lNjsSYpPVg4muIrEKO7HPasOtiBPowNXMbc56lJ6aoS5kr7huLYF+KwTmjaH KRuU7TwuVhP7c8OTmZvAUNtXpV0H52HEsp+NO4iioyL3UTWaoD4VToStdif4SiqAOu5y kLUQD6/rxSPcJBnC3fUP4WJXJKpR/Vcy69FOtZeK/Cm5S/DY73F2ZN47VMZCVjggaW2J SA1OB2vr+m+g60L9pe8TN21S1T8xd3QO3DmySA/0Xol5EYYSbklUAWJXg6KSdOHsT+zp GlyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G+EKCJNwn+0jFeGZ8T3IHbGM+D1iiujj1KVvmsIMQMw=; b=S1KTUvnsV1hyqiR/SSQpbhBPPGlajvwxSvciIrv9ovRkgU/unG0WLxyhWCv07N2qzn 1jK/bMwuL5tx1utk4k1CXXroQxXuE+r6qGN/erNXdDlDdRxcgyIRt7Xg391BsWCHKl/n mJ85Htj5tJ32GIHEkTR+YQEWvU4HguReMko8TaTgsVPWjqhH3UDLSWpjf2rHumk8fekZ momMM0pNi7Bwxi63dKJygf0r4ZI9t1rH3iEZksT5a8LuFo32yyjWjUN2P5kkMVzjGWHi CTqpHng6clmm+8z9fl/Oq6IhMhXC2vZIKxah3N+9HvNOYVMgLVW3bjOHS/pxBOTAX8lr Q0HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=8DPRIzT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l19-20020a170902eb1300b001a05347d088si5077022plb.201.2023.03.15.04.22.28; Wed, 15 Mar 2023 04:22:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=8DPRIzT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232018AbjCOLHW (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231714AbjCOLGo (ORCPT ); Wed, 15 Mar 2023 07:06:44 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE41F80E25 for ; Wed, 15 Mar 2023 04:06:36 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id bh21-20020a05600c3d1500b003ed1ff06fb0so904332wmb.3 for ; Wed, 15 Mar 2023 04:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G+EKCJNwn+0jFeGZ8T3IHbGM+D1iiujj1KVvmsIMQMw=; b=8DPRIzT+e47FNhbQ2zSHDerldk8oZzC4RC0B2tmmmy1Kj1e0ivYvTz59s6Q18Xk4HX ZVRJ8qt/wGDm+18q2CC7Q1ZgnD/mOgeUfc1krkPQNCrN4ioOgn29i3U9UMESAEzWWtBy UTqZr/0c3BwBn0sAgC9Rm/W56WpvNcBJuDbjg/DZwDLTNJ3jsRnCqPClr255VJkVnyw6 RKLDU7Whlixf80Cb0KAniBGMYyy8/Bg7qelqNGw9MImxh3vEhfZBaaPv4xd5gGdgGT1c JNbQo6HCJIUMj2ro0U4c44qoNIZ+fitTZaU2tM20K5/WUR3WEYdmDUuH0VnedMa2fnTR p8Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G+EKCJNwn+0jFeGZ8T3IHbGM+D1iiujj1KVvmsIMQMw=; b=zXxAIaV2fxi8+n/2pBwXtfY2laqZEm901hzXM091oYzKQyb+qJgkhKVsGbdQcs/3RL TE8vlh3oDIEcK9CZCOWZDXvYps0NstEoaQkcmaWNfTVELLO06IrCSr2F/LXPuzDw97Ow 2FKF/Wq2jnPWBRvlcjkgLw6mektSN4vGPTx4wBtxzm0mSWEZD8XiF5h1r4X1ElZAXFmX 7VTCu0JZKYHlQTpGXHoOhiZWf9B20Ae10kjTXrRIMf/O6E5gbUMn7k+yrFgy/J8kCeON zjMNOUOHQgx4NGWa8PC+36/4ovsUc1Dp6hII0Pwrel2ZaS0Uh2pWG/V/41cNXWctq9gy E1Fw== X-Gm-Message-State: AO0yUKWtFEjs+ka8Mgm3i8/EwaQeHkxEMQ8PvvRodaA9CNvGxvgNbaxd xOK2tQjMB4AM8tXnsuv5KsgQ4w== X-Received: by 2002:a05:600c:154b:b0:3ea:e554:77fe with SMTP id f11-20020a05600c154b00b003eae55477femr18003374wmg.12.1678878396165; Wed, 15 Mar 2023 04:06:36 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:35 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 13/16] can: m_can: Introduce a tx_fifo_in_flight counter Date: Wed, 15 Mar 2023 12:05:43 +0100 Message-Id: <20230315110546.2518305-14-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760432607154040141?= X-GMAIL-MSGID: =?utf-8?q?1760432607154040141?= Keep track of the number of transmits in flight. This patch prepares the driver to control the network interface queue based on this counter. By itself this counter be implemented with an atomic, but as we need to do other things in the critical sections later I am using a spinlock instead. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 41 ++++++++++++++++++++++++++++++++++- drivers/net/can/m_can/m_can.h | 4 ++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 27d36bcc094c..4ad8f08f8284 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -442,6 +442,7 @@ static u32 m_can_get_timestamp(struct m_can_classdev *cdev) static void m_can_clean(struct net_device *net) { struct m_can_classdev *cdev = netdev_priv(net); + unsigned long irqflags; for (int i = 0; i != cdev->tx_fifo_size; ++i) { if (!cdev->tx_ops[i].skb) @@ -453,6 +454,10 @@ static void m_can_clean(struct net_device *net) for (int i = 0; i != cdev->can.echo_skb_max; ++i) can_free_echo_skb(cdev->net, i, NULL); + + spin_lock_irqsave(&cdev->tx_handling_spinlock, irqflags); + cdev->tx_fifo_in_flight = 0; + spin_unlock_irqrestore(&cdev->tx_handling_spinlock, irqflags); } /* For peripherals, pass skb to rx-offload, which will push skb from @@ -1023,6 +1028,24 @@ static void m_can_tx_update_stats(struct m_can_classdev *cdev, stats->tx_packets++; } +static void m_can_finish_tx(struct m_can_classdev *cdev, int transmitted) +{ + unsigned long irqflags; + + spin_lock_irqsave(&cdev->tx_handling_spinlock, irqflags); + cdev->tx_fifo_in_flight -= transmitted; + spin_unlock_irqrestore(&cdev->tx_handling_spinlock, irqflags); +} + +static void m_can_start_tx(struct m_can_classdev *cdev) +{ + unsigned long irqflags; + + spin_lock_irqsave(&cdev->tx_handling_spinlock, irqflags); + ++cdev->tx_fifo_in_flight; + spin_unlock_irqrestore(&cdev->tx_handling_spinlock, irqflags); +} + static int m_can_echo_tx_event(struct net_device *dev) { u32 txe_count = 0; @@ -1032,6 +1055,7 @@ static int m_can_echo_tx_event(struct net_device *dev) int i = 0; int err = 0; unsigned int msg_mark; + int processed = 0; struct m_can_classdev *cdev = netdev_priv(dev); @@ -1061,12 +1085,15 @@ static int m_can_echo_tx_event(struct net_device *dev) /* update stats */ m_can_tx_update_stats(cdev, msg_mark, timestamp); + ++processed; } if (ack_fgi != -1) m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK, ack_fgi)); + m_can_finish_tx(cdev, processed); + return err; } @@ -1161,6 +1188,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) timestamp = m_can_get_timestamp(cdev); m_can_tx_update_stats(cdev, 0, timestamp); netif_wake_queue(dev); + m_can_finish_tx(cdev, 1); } } else { if (ir & (IR_TEFN | IR_TEFW)) { @@ -1846,11 +1874,22 @@ static netdev_tx_t m_can_start_peripheral_xmit(struct m_can_classdev *cdev, } netif_stop_queue(cdev->net); + + m_can_start_tx(cdev); + m_can_tx_queue_skb(cdev, skb); return NETDEV_TX_OK; } +static netdev_tx_t m_can_start_fast_xmit(struct m_can_classdev *cdev, + struct sk_buff *skb) +{ + m_can_start_tx(cdev); + + return m_can_tx_handler(cdev, skb); +} + static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -1862,7 +1901,7 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, if (cdev->is_peripheral) return m_can_start_peripheral_xmit(cdev, skb); else - return m_can_tx_handler(cdev, skb); + return m_can_start_fast_xmit(cdev, skb); } static int m_can_open(struct net_device *dev) diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index 2e1a52980a18..e230cf320a6c 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -109,6 +109,10 @@ struct m_can_classdev { // Store this internally to avoid fetch delays on peripheral chips int tx_fifo_putidx; + /* Protects shared state between start_xmit and m_can_isr */ + spinlock_t tx_handling_spinlock; + int tx_fifo_in_flight; + struct m_can_tx_op *tx_ops; int tx_fifo_size; int next_tx_op; From patchwork Wed Mar 15 11:05:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2268636wrd; Wed, 15 Mar 2023 04:23:49 -0700 (PDT) X-Google-Smtp-Source: AK7set8/75AQsMKIUG6L7J6jc7ziN6PzqRHi6BdcVgIVmq/b0oTFRKWeY51JWqqkwVKJfaotgMQ4 X-Received: by 2002:a05:6a21:998b:b0:ce:8028:e0ac with SMTP id ve11-20020a056a21998b00b000ce8028e0acmr47959064pzb.44.1678879428870; Wed, 15 Mar 2023 04:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678879428; cv=none; d=google.com; s=arc-20160816; b=RSl69X0o0XWIv71WNOvHrlvUoEtP519LbRFXOzRkbqmXGrfZSDWzx8/5CaOCqgbWv1 UQO+gsiMcQ//Chk4V//7iSMYgl9rzGwLxpMd/g2gvUDC2I82vikcWoZRocpjXN9vv7Z+ VgqsF+tGgR7ZAk1FX3jmUcdlK2kZU5jXG+y5P+AQDDRGSTPl4R+1FSEBurqAKrB6ID8S 6LioTnbN4WHkSZlZaw5+iZkVbKDkNPGNqqasBgWJ64EpXelXNH2/0zOGTwFbuTimRgHB FddUi0l2hY3Pz6RZRCVJSd5XXE2c4D9Q9lo8O+1EHd6uSw3VbLkI/nFjmuIQHUpny9o2 f4Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ypZdWnRNDTGXAnkPh6LVaKjwNg77jYO2dJofBGuM+QE=; b=GTyBx1jn1HXXGnF/b375f/wLvC7tB83ksw87QWV8Hqw7CUrSJ1QfEhaxk4QSxCmDUy QgS8Ol4Rw+19WdtF9uAvsZWXE8rz/5WG6xt6BvwEfkaEjMKoCtdKNCBKiwMXxHfHnC+s uZsaY6gyM3spynd9RtmVbb/Gt7KVoiDiXK22vYqWCq/f6JY2mXil0+zyGGATZAJgAl/T DDdGjTjwRWuMsIEjieeTQJ77JshlTGj5TU+tgoymSQZgHrEiU8fgGO4wS9GHI9xJxm8W gdrc3rXrs502NQQY3ISQDVONLqMb4BjYINdIpIYDi4lisn2KlD58Ej0Vq3jxOJiLYeFg 2M3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=huSERv9r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 1-20020a630f41000000b00502f145822bsi4620044pgp.345.2023.03.15.04.23.19; Wed, 15 Mar 2023 04:23:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=huSERv9r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231871AbjCOLHh (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbjCOLGr (ORCPT ); Wed, 15 Mar 2023 07:06:47 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72C4A8092A for ; Wed, 15 Mar 2023 04:06:38 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id c8-20020a05600c0ac800b003ed2f97a63eso820518wmr.3 for ; Wed, 15 Mar 2023 04:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ypZdWnRNDTGXAnkPh6LVaKjwNg77jYO2dJofBGuM+QE=; b=huSERv9rU/L1D67HT8F+JyU+EjfQBPwOlzECRS42tJwk7EuY0f4UVfiHb6pCDxx6IL qpW1WmSNslFEQPTbN87jNWljG/W5BbwNlYgHCy591VuNKF/ixGEOj00+E3Ax9/k4kpvw SfzTFxH00T4GVbhZMHYLlEpH/t7JddT/QBzZGLjP6ydJfTJxUFPBcCuygRukYq5TA6N6 mkTzlVDQNvKq2kfRbq6ZoF8EP9/8yeW3viA8QkpSQewnnGfAnnXW/Qmh38hbl526ihyX v3N1zt6yadwXVTK21RxfteRtTpNpzsIF3V3Ejn8K3DCx2nlkKHqyAcWYRteQtWlGn/m6 VJJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ypZdWnRNDTGXAnkPh6LVaKjwNg77jYO2dJofBGuM+QE=; b=f5PVnl5psxzEmFWXL5UNgGpSrsgEWHqLYOKFT5/BDfUZunHyceUqRngh5+W9XtNKIY OGUAzKVndQapTLOWLCEylfxyODMZiCkKQ6RjJViIIVh6CM5AzOcAPHnp7WSZKpDE5VHT Uyw3mRAijxs/SwCosQLnYSI3GCVBWNN6uY+KE5n5eiP009zy/AYPiW5ssSuVwzOtYaex UDb3ohS6vrz8+0kamkR9EOqEwPF1c8OLhRjfab6bd783z0neFV9f37zk+hps1IaVeIWf m1QSYy1DJRKaD93KvDVmxC0G9bZyT9RFVtvmfJ/niLlLbRiN51pSWCFlC6D3+vhNFpFk 4IoA== X-Gm-Message-State: AO0yUKUgkXYk7lzXO61JeZkn/oes0bbYk2ItT8BetI98tZ6YLgf5VkiA j0rdlHkUlsAFdfR/Rj+SV67QtQ== X-Received: by 2002:a05:600c:3c9e:b0:3e1:f8af:8772 with SMTP id bg30-20020a05600c3c9e00b003e1f8af8772mr17124880wmb.9.1678878397040; Wed, 15 Mar 2023 04:06:37 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:36 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 14/16] can: m_can: Use tx_fifo_in_flight for netif_queue control Date: Wed, 15 Mar 2023 12:05:44 +0100 Message-Id: <20230315110546.2518305-15-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760432676063071818?= X-GMAIL-MSGID: =?utf-8?q?1760432676063071818?= The network queue is currently always stopped in start_xmit and continued in the interrupt handler. This is not possible anymore if we want to keep multiple transmits in flight in parallel. Use the previously introduced tx_fifo_in_flight counter to control the network queue instead. This has the benefit of not needing to ask the hardware about fifo status. This patch stops the network queue in start_xmit if the number of transmits in flight reaches the size of the fifo and wakes up the queue from the interrupt handler once the transmits in flight drops below the fifo size. This means any skbs over the limit will be rejected immediately in start_xmit (it shouldn't be possible at all to reach that state anyways). The maximum number of transmits in flight is the size of the fifo. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 71 +++++++++++++---------------------- 1 file changed, 26 insertions(+), 45 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 4ad8f08f8284..3cb3d01e1a61 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -370,16 +370,6 @@ m_can_txe_fifo_read(struct m_can_classdev *cdev, u32 fgi, u32 offset, u32 *val) return cdev->ops->read_fifo(cdev, addr_offset, val, 1); } -static inline bool _m_can_tx_fifo_full(u32 txfqs) -{ - return !!(txfqs & TXFQS_TFQF); -} - -static inline bool m_can_tx_fifo_full(struct m_can_classdev *cdev) -{ - return _m_can_tx_fifo_full(m_can_read(cdev, M_CAN_TXFQS)); -} - static void m_can_config_endisable(struct m_can_classdev *cdev, bool enable) { u32 cccr = m_can_read(cdev, M_CAN_CCCR); @@ -1033,17 +1023,31 @@ static void m_can_finish_tx(struct m_can_classdev *cdev, int transmitted) unsigned long irqflags; spin_lock_irqsave(&cdev->tx_handling_spinlock, irqflags); + if (cdev->tx_fifo_in_flight >= cdev->tx_fifo_size && transmitted > 0) + netif_wake_queue(cdev->net); cdev->tx_fifo_in_flight -= transmitted; spin_unlock_irqrestore(&cdev->tx_handling_spinlock, irqflags); } -static void m_can_start_tx(struct m_can_classdev *cdev) +static netdev_tx_t m_can_start_tx(struct m_can_classdev *cdev) { unsigned long irqflags; + int tx_fifo_in_flight; spin_lock_irqsave(&cdev->tx_handling_spinlock, irqflags); - ++cdev->tx_fifo_in_flight; + tx_fifo_in_flight = cdev->tx_fifo_in_flight + 1; + if (tx_fifo_in_flight >= cdev->tx_fifo_size) { + netif_stop_queue(cdev->net); + if (tx_fifo_in_flight > cdev->tx_fifo_size) { + netdev_err(cdev->net, "hard_xmit called while TX FIFO full\n"); + spin_unlock_irqrestore(&cdev->tx_handling_spinlock, irqflags); + return NETDEV_TX_BUSY; + } + } + cdev->tx_fifo_in_flight = tx_fifo_in_flight; spin_unlock_irqrestore(&cdev->tx_handling_spinlock, irqflags); + + return NETDEV_TX_OK; } static int m_can_echo_tx_event(struct net_device *dev) @@ -1187,7 +1191,6 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) if (cdev->is_peripheral) timestamp = m_can_get_timestamp(cdev); m_can_tx_update_stats(cdev, 0, timestamp); - netif_wake_queue(dev); m_can_finish_tx(cdev, 1); } } else { @@ -1195,10 +1198,6 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) /* New TX FIFO Element arrived */ if (m_can_echo_tx_event(dev) != 0) goto out_fail; - - if (netif_queue_stopped(dev) && - !m_can_tx_fifo_full(cdev)) - netif_wake_queue(dev); } } @@ -1719,7 +1718,6 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, struct net_device *dev = cdev->net; struct id_and_dlc fifo_header; u32 cccr, fdflags; - u32 txfqs; int err; int putidx; @@ -1776,24 +1774,6 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, u8 len_padded = DIV_ROUND_UP(cf->len, 4); /* Transmit routine for version >= v3.1.x */ - txfqs = m_can_read(cdev, M_CAN_TXFQS); - - /* Check if FIFO full */ - if (_m_can_tx_fifo_full(txfqs)) { - /* This shouldn't happen */ - netif_stop_queue(dev); - netdev_warn(dev, - "TX queue active although FIFO is full."); - - if (cdev->is_peripheral) { - kfree_skb(skb); - dev->stats.tx_dropped++; - return NETDEV_TX_OK; - } else { - return NETDEV_TX_BUSY; - } - } - /* get put index for frame */ putidx = cdev->tx_fifo_putidx; @@ -1830,11 +1810,6 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, m_can_write(cdev, M_CAN_TXBAR, (1 << putidx)); cdev->tx_fifo_putidx = (++cdev->tx_fifo_putidx >= cdev->can.echo_skb_max ? 0 : cdev->tx_fifo_putidx); - - /* stop network queue if fifo full */ - if (m_can_tx_fifo_full(cdev) || - m_can_next_echo_skb_occupied(dev, putidx)) - netif_stop_queue(dev); } return NETDEV_TX_OK; @@ -1868,14 +1843,16 @@ static void m_can_tx_queue_skb(struct m_can_classdev *cdev, struct sk_buff *skb) static netdev_tx_t m_can_start_peripheral_xmit(struct m_can_classdev *cdev, struct sk_buff *skb) { + netdev_tx_t err; + if (cdev->can.state == CAN_STATE_BUS_OFF) { m_can_clean(cdev->net); return NETDEV_TX_OK; } - netif_stop_queue(cdev->net); - - m_can_start_tx(cdev); + err = m_can_start_tx(cdev); + if (err != NETDEV_TX_OK) + return err; m_can_tx_queue_skb(cdev, skb); @@ -1885,7 +1862,11 @@ static netdev_tx_t m_can_start_peripheral_xmit(struct m_can_classdev *cdev, static netdev_tx_t m_can_start_fast_xmit(struct m_can_classdev *cdev, struct sk_buff *skb) { - m_can_start_tx(cdev); + netdev_tx_t err; + + err = m_can_start_tx(cdev); + if (err != NETDEV_TX_OK) + return err; return m_can_tx_handler(cdev, skb); } From patchwork Wed Mar 15 11:05:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70143 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2267816wrd; Wed, 15 Mar 2023 04:21:51 -0700 (PDT) X-Google-Smtp-Source: AK7set+M4sGMdOSxE1ISSDxd+2YyOFYkSOJ0eEG9T2Xh/3TLPRm3BJzkp4MJUCUjiBkHF6h8ABRD X-Received: by 2002:a05:6a20:431a:b0:cb:aacb:312c with SMTP id h26-20020a056a20431a00b000cbaacb312cmr46103571pzk.27.1678879310861; Wed, 15 Mar 2023 04:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678879310; cv=none; d=google.com; s=arc-20160816; b=Yun2+K4hLFi1o4cpnHfF6CvHuFlBgP1pvtDs41wnQ2r0raHimFBLctBcz5YAaQ63GU SSdyCgKwAPrrMVPCk1LeX8dEUVKjlWVRYKTpb1d9XusXvTfafQxvDKNg9JlKdFp/+pF/ XMGVuwQMzUwzMjrN0v/impe62HW4FzRvACU991+3a6K3hOZK8LZqWrcEhk8rfz9hZvUO bv64kztrmeT/7cqpsA9bkAEbwyMiiiFvW/0zWfZB3j7kWWrnyMuJkMl0QL6JeQebygn9 cJr32jIs5mHJeZF5aGfR0+T2pma1+vjYp7Rc8Ch2rUmfGcvE7sjg3JErBDpyqD1RHoZt RN9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LD4Xs3iN23TSbUWYlmTbPodYFQvDAfJaowT5cFCRCnM=; b=YkyEDsGVovuS3h80w/+Z/ZSPLQhgvbxtGBZnjwag1eXA+zTKqqDTR0rolHQJQGD+vx 3RLQpw9+R0nOOJgiiPp5zeLmWl9kifjeCyIeZCuTFjKPi97kDMmadlhxeLe2QGeAYVGC N73o4AYzkFkKfAEfgl5KWafd/+cOfNAeNgvyvcp5KmfK9yyIeKPJxLPtdojQQPVFpurA QmQEsxHmtTbOKccQGxE7Zxi+ARjlejNZJahHDUAUqlWV2r4h9aw94yCB1h80FG7Gqd7Y d2cZ9cYOBqKPVfc4A/NPInU9gPOaKSJVYI+s9PeoKteOKymghSdunj7NhJoFQQjTEe4m Ve3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=VoFEESwU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6-20020a635106000000b004d184dbf598si4715191pgb.519.2023.03.15.04.21.35; Wed, 15 Mar 2023 04:21:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=VoFEESwU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231849AbjCOLHr (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231532AbjCOLGs (ORCPT ); Wed, 15 Mar 2023 07:06:48 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89B9780921 for ; Wed, 15 Mar 2023 04:06:38 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id k25-20020a7bc419000000b003ed23114fa7so819372wmi.4 for ; Wed, 15 Mar 2023 04:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LD4Xs3iN23TSbUWYlmTbPodYFQvDAfJaowT5cFCRCnM=; b=VoFEESwUBxmtW5+nFMxby7XevZg++Mn56tGd/ZTLrjpLfzXJod8dWaZ2eV8vwQbYyf txwnnaG2WiOSY4BzyI1yZTIdL9HiwlOY95Uq/C+XWMDzKJ3LP7/i5rVQlQunamZ6d15A 4Ckj2kAv4yokvb600hQmZM41P8+aHd0TXYRfApazNhEfLALIQCGuGEWtz7QLmwwRsdXD SmyLsqq1lIctg5ZmkjNvrh2D/Ga1oowyyb4WaFj6MHiEMY7WKfAgbUK85IPpX+bcpVSP OG+WQWs6ESGUqOdj2cCCq2jp6TO+5gAFivnXHjK46ztFbpjeNuf2wHeVwwe3FhSDA3F9 VswQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LD4Xs3iN23TSbUWYlmTbPodYFQvDAfJaowT5cFCRCnM=; b=OYGlPTFPGyuGqgnB49T9JE7P+ds1blV9DUWmM5GIuqCjz6XYmOA7QJQTAgrNuiIWRA 1Iinw31UDcyOcdwkDf43TEJsoEn0eGGEMIni9StOHN1DEo4GMRbHtAJZdTSKf0FzIe9T zeHV2LQ7gcl3r3ooHIe7bNvOL5hnBDainA2HgzIrnemMlbHdqT1XXpBEtxyVH4rQYils MDvVqSsBxAyNIKl1yhLHD1t9MtYOF5Mz0V/xSWj8lGqZu8xJpqTqAJn2iWKfvIHFa6n1 9t+FX/siW3I/uYTGQeAbvqgpWE8HGtzlwYSddQr/fPfzxKXYS7uuroJNGliSJI9s3rAw IGgA== X-Gm-Message-State: AO0yUKW1CZe2X9z3XmuIbbqo04mBRR/GdV1Rc+ujX/1NqWNTx7sT/LS1 kvK1uqp7WNW1jR0336llSaGFJg== X-Received: by 2002:a05:600c:a48:b0:3ed:245f:97a with SMTP id c8-20020a05600c0a4800b003ed245f097amr9194559wmq.19.1678878398171; Wed, 15 Mar 2023 04:06:38 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:37 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 15/16] can: m_can: Implement BQL Date: Wed, 15 Mar 2023 12:05:45 +0100 Message-Id: <20230315110546.2518305-16-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760432551861700934?= X-GMAIL-MSGID: =?utf-8?q?1760432551861700934?= Implement byte queue limiting in preparation for the use of xmit_more(). Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 49 +++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 3cb3d01e1a61..63d6e95717e3 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -445,6 +445,8 @@ static void m_can_clean(struct net_device *net) for (int i = 0; i != cdev->can.echo_skb_max; ++i) can_free_echo_skb(cdev->net, i, NULL); + netdev_reset_queue(cdev->net); + spin_lock_irqsave(&cdev->tx_handling_spinlock, irqflags); cdev->tx_fifo_in_flight = 0; spin_unlock_irqrestore(&cdev->tx_handling_spinlock, irqflags); @@ -999,29 +1001,34 @@ static int m_can_poll(struct napi_struct *napi, int quota) * echo. timestamp is used for peripherals to ensure correct ordering * by rx-offload, and is ignored for non-peripherals. */ -static void m_can_tx_update_stats(struct m_can_classdev *cdev, - unsigned int msg_mark, - u32 timestamp) +static unsigned int m_can_tx_update_stats(struct m_can_classdev *cdev, + unsigned int msg_mark, u32 timestamp) { struct net_device *dev = cdev->net; struct net_device_stats *stats = &dev->stats; + unsigned int frame_len; if (cdev->is_peripheral) stats->tx_bytes += can_rx_offload_get_echo_skb(&cdev->offload, msg_mark, timestamp, - NULL); + &frame_len); else - stats->tx_bytes += can_get_echo_skb(dev, msg_mark, NULL); + stats->tx_bytes += can_get_echo_skb(dev, msg_mark, &frame_len); stats->tx_packets++; + + return frame_len; } -static void m_can_finish_tx(struct m_can_classdev *cdev, int transmitted) +static void m_can_finish_tx(struct m_can_classdev *cdev, int transmitted, + int transmitted_frame_len) { unsigned long irqflags; + netdev_completed_queue(cdev->net, transmitted, transmitted_frame_len); + spin_lock_irqsave(&cdev->tx_handling_spinlock, irqflags); if (cdev->tx_fifo_in_flight >= cdev->tx_fifo_size && transmitted > 0) netif_wake_queue(cdev->net); @@ -1060,6 +1067,7 @@ static int m_can_echo_tx_event(struct net_device *dev) int err = 0; unsigned int msg_mark; int processed = 0; + int processed_frame_len = 0; struct m_can_classdev *cdev = netdev_priv(dev); @@ -1088,7 +1096,9 @@ static int m_can_echo_tx_event(struct net_device *dev) fgi = (++fgi >= cdev->mcfg[MRAM_TXE].num ? 0 : fgi); /* update stats */ - m_can_tx_update_stats(cdev, msg_mark, timestamp); + processed_frame_len += m_can_tx_update_stats(cdev, msg_mark, + timestamp); + ++processed; } @@ -1096,7 +1106,7 @@ static int m_can_echo_tx_event(struct net_device *dev) m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK, ack_fgi)); - m_can_finish_tx(cdev, processed); + m_can_finish_tx(cdev, processed, processed_frame_len); return err; } @@ -1187,11 +1197,12 @@ static irqreturn_t m_can_isr(int irq, void *dev_id) if (ir & IR_TC) { /* Transmission Complete Interrupt*/ u32 timestamp = 0; + unsigned int frame_len; if (cdev->is_peripheral) timestamp = m_can_get_timestamp(cdev); - m_can_tx_update_stats(cdev, 0, timestamp); - m_can_finish_tx(cdev, 1); + frame_len = m_can_tx_update_stats(cdev, 0, timestamp); + m_can_finish_tx(cdev, 1, frame_len); } } else { if (ir & (IR_TEFN | IR_TEFW)) { @@ -1720,6 +1731,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, u32 cccr, fdflags; int err; int putidx; + unsigned int frame_len = can_skb_get_frame_len(skb); /* Generate ID field for TX buffer Element */ /* Common to all supported M_CAN versions */ @@ -1765,7 +1777,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, } m_can_write(cdev, M_CAN_TXBTIE, 0x1); - can_put_echo_skb(skb, dev, 0, 0); + can_put_echo_skb(skb, dev, 0, frame_len); m_can_write(cdev, M_CAN_TXBAR, 0x1); /* End of xmit function for version 3.0.x */ @@ -1804,7 +1816,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, /* Push loopback echo. * Will be looped back on TX interrupt based on message marker */ - can_put_echo_skb(skb, dev, putidx, 0); + can_put_echo_skb(skb, dev, putidx, frame_len); /* Enable TX FIFO element to start transfer */ m_can_write(cdev, M_CAN_TXBAR, (1 << putidx)); @@ -1875,14 +1887,23 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct m_can_classdev *cdev = netdev_priv(dev); + netdev_tx_t ret; + unsigned int frame_len; if (can_dev_dropped_skb(dev, skb)) return NETDEV_TX_OK; + frame_len = can_skb_get_frame_len(skb); + if (cdev->is_peripheral) - return m_can_start_peripheral_xmit(cdev, skb); + ret = m_can_start_peripheral_xmit(cdev, skb); else - return m_can_start_fast_xmit(cdev, skb); + ret = m_can_start_fast_xmit(cdev, skb); + + if (ret == NETDEV_TX_OK) + netdev_sent_queue(dev, frame_len); + + return ret; } static int m_can_open(struct net_device *dev) From patchwork Wed Mar 15 11:05:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70140 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2267566wrd; Wed, 15 Mar 2023 04:21:09 -0700 (PDT) X-Google-Smtp-Source: AK7set/pi1YtozwE4X7vIofuPFAI7pr98SHk+C+QWLqFkfD/UbriXQvBbeIJQy9PE/CvAhCT+yUG X-Received: by 2002:a05:6a20:6715:b0:d4:9b95:bdf2 with SMTP id q21-20020a056a20671500b000d49b95bdf2mr8291572pzh.32.1678879269614; Wed, 15 Mar 2023 04:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678879269; cv=none; d=google.com; s=arc-20160816; b=ngxOnoLX2hiC12fW0XXfPNqOSCtwyjtFpWebb6lCmSS08qffcZs67z2TuLZ8stmYwV WujRdaAlK5HyV3dbcLTwS/78D7swqF+rpum+K6qELBkc8tyG/eWw23ot8P9SWgKsGqCN Flyh9QIrMbeWnocGZV+d8ZaxmKrQ48ub8nt9USwQMyAuoGpwme3Z1uCz8FfEf2pJRlH9 gUO+44GpUwyaP/F1wxp/lP8vyakPVhsxqAPUwx+rEeEjTg1LGFI4L3kMPznB087SzgDp pL5B8rW3tl4X1ntbr1XeQ9pgFb7VuWGULpyZeub/2GdjnGR6PwgNycAiSu0OyYhu0Pe4 QaXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Mmse28A41MDTbbOZve6pZwq9r+Apwq0OhP9O66IiwcY=; b=QygGlOr8bSw5Mc3KZE5z7KdWvaNNZx3sD4vZyJk4hC/kct8EntPfGyiA0W/pWxMgnh rbKrj4yeyPzNQuppdddCk6Rc5x2mNEqXuFcmPvAFl4HVQU+yUO3ISbAoUUjic6KPKCm0 tIJ1p8lAXcoCSDwE9tSHCVR6vO9aN4DNSuMVK6ZiphxBtBiOAXwBrSZIGOC5z3KTu6Bl JP+D0UL4LSM83ZlUJqhWhX6EyKtBStHuGc2vngjvC77gQczXlcLbyFJMf9xGAO3zG70v AC5/gbcDUSIoWKrwfnJPP8WfSXesWFotPdn28ihEG7nEP1nplQa2/TQ4xoNg1ueNSwwV Bq+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=snClEnuf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s198-20020a632ccf000000b00508bbf1942esi4662294pgs.678.2023.03.15.04.20.53; Wed, 15 Mar 2023 04:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=snClEnuf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231975AbjCOLHl (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231784AbjCOLGs (ORCPT ); Wed, 15 Mar 2023 07:06:48 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E26180E01 for ; Wed, 15 Mar 2023 04:06:39 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id az3-20020a05600c600300b003ed2920d585so827487wmb.2 for ; Wed, 15 Mar 2023 04:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mmse28A41MDTbbOZve6pZwq9r+Apwq0OhP9O66IiwcY=; b=snClEnuf/onBHGLARSF8/jnvi0Vvmuoe8oIpj23fRHjXeNGHBHagrkhTRPTTAZctwp KY6fwU4DKtoh+7RderEhs/cYX2QZsOV3ccEils52G46N40xJDoiuEIil887N7p/3bllk Uz9dAzyBGRF19ElieVACbNB4ktTlIUlbn2SRLv7AqprDuYYF0MnviKWXWJE4tyDscNtX E520AfueYvRNg4iE3kPsxq0AOWNcujxibHdaMmsXeSXlVtVg52yMV5Rw3lZSGfGCXSS6 JN7ZPmPiVc6TfeoPK2brrpTki1Y2OFbi7IKRAMP94dS8MkRh7y08v8G/lbLZwjPwKvqz BJJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mmse28A41MDTbbOZve6pZwq9r+Apwq0OhP9O66IiwcY=; b=cynMuMVgi7TfOaZClmKHnUUUPKosx6vN95rLhrcZGOoNCUqm5v6mNHK01ZeAnih1XJ OL2KzTmRPM/utX9fyqC3VqoNv1/Se1G5QbTZaz6N3OvVjNOt1/CmCF+TLhSTK5dAbMvg QbhVC0/otYhdrDrz6VGljB+5Z0BxSRZuQuzu6LVltd3V1h8jpdiq/q77xZhArMUlnSEx 5Af8olhwoJn50Mxhx39Mhww4JM7l9xIP4CeaY85m6vuQLfFplfobio9c+PUoPWCpWitA Fw+tV2IKXACTB5Y2kBfGrDD+KHgjAgJzEQ3on4h1MTCRqSm5QvGjP4/H6AcxlGLGsOh+ RWhw== X-Gm-Message-State: AO0yUKWyqDkSixVhH8lRYPoZxJy0h2NYyT/ow+BFwtfqu2zTt3fnNx9M uBQn0MAuj8aRlJJZdciiqz4xlQ== X-Received: by 2002:a05:600c:3588:b0:3ed:3993:6a93 with SMTP id p8-20020a05600c358800b003ed39936a93mr370247wmq.19.1678878399164; Wed, 15 Mar 2023 04:06:39 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:38 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 16/16] can: m_can: Implement transmit submission coalescing Date: Wed, 15 Mar 2023 12:05:46 +0100 Message-Id: <20230315110546.2518305-17-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760432509105261243?= X-GMAIL-MSGID: =?utf-8?q?1760432509105261243?= m_can supports submitting multiple transmits with one register write. This is an interesting option to reduce the number of SPI transfers for peripheral chips. The m_can_tx_op is extended with a bool that signals if it is the last transmission and the submit should be executed immediately. The worker then writes the skb to the FIFO and submits it only if the submit bool is set. If it isn't set, the worker will write the next skb which is waiting in the workqueue to the FIFO, etc. Signed-off-by: Markus Schneider-Pargmann --- Notes: Notes: - I ran into lost messages in the receive FIFO when using this implementation. I guess this only shows up with my test setup in loopback mode and maybe not enough CPU power. - I put this behind the tx-frames ethtool coalescing option as we do wait before submitting packages but it is something different than the tx-frames-irq option. I am not sure if this is the correct option, please let me know. drivers/net/can/m_can/m_can.c | 55 ++++++++++++++++++++++++++++++++--- drivers/net/can/m_can/m_can.h | 6 ++++ 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 63d6e95717e3..1f758894e122 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1508,6 +1508,9 @@ static int m_can_start(struct net_device *dev) if (ret) return ret; + netdev_queue_set_dql_min_limit(netdev_get_tx_queue(cdev->net, 0), + cdev->tx_max_coalesced_frames); + cdev->can.state = CAN_STATE_ERROR_ACTIVE; m_can_enable_all_interrupts(cdev); @@ -1818,8 +1821,13 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, */ can_put_echo_skb(skb, dev, putidx, frame_len); - /* Enable TX FIFO element to start transfer */ - m_can_write(cdev, M_CAN_TXBAR, (1 << putidx)); + if (cdev->is_peripheral) { + /* Delay enabling TX FIFO element */ + cdev->tx_peripheral_submit |= BIT(putidx); + } else { + /* Enable TX FIFO element to start transfer */ + m_can_write(cdev, M_CAN_TXBAR, BIT(putidx)); + } cdev->tx_fifo_putidx = (++cdev->tx_fifo_putidx >= cdev->can.echo_skb_max ? 0 : cdev->tx_fifo_putidx); } @@ -1832,6 +1840,17 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, return NETDEV_TX_BUSY; } +static void m_can_tx_submit(struct m_can_classdev *cdev) +{ + if (cdev->version == 30) + return; + if (!cdev->is_peripheral) + return; + + m_can_write(cdev, M_CAN_TXBAR, cdev->tx_peripheral_submit); + cdev->tx_peripheral_submit = 0; +} + static void m_can_tx_work_queue(struct work_struct *ws) { struct m_can_tx_op *op = container_of(ws, struct m_can_tx_op, work); @@ -1840,11 +1859,15 @@ static void m_can_tx_work_queue(struct work_struct *ws) op->skb = NULL; m_can_tx_handler(cdev, skb); + if (op->submit) + m_can_tx_submit(cdev); } -static void m_can_tx_queue_skb(struct m_can_classdev *cdev, struct sk_buff *skb) +static void m_can_tx_queue_skb(struct m_can_classdev *cdev, struct sk_buff *skb, + bool submit) { cdev->tx_ops[cdev->next_tx_op].skb = skb; + cdev->tx_ops[cdev->next_tx_op].submit = submit; queue_work(cdev->tx_wq, &cdev->tx_ops[cdev->next_tx_op].work); ++cdev->next_tx_op; @@ -1856,6 +1879,7 @@ static netdev_tx_t m_can_start_peripheral_xmit(struct m_can_classdev *cdev, struct sk_buff *skb) { netdev_tx_t err; + bool submit; if (cdev->can.state == CAN_STATE_BUS_OFF) { m_can_clean(cdev->net); @@ -1866,7 +1890,15 @@ static netdev_tx_t m_can_start_peripheral_xmit(struct m_can_classdev *cdev, if (err != NETDEV_TX_OK) return err; - m_can_tx_queue_skb(cdev, skb); + ++cdev->nr_txs_without_submit; + if (cdev->nr_txs_without_submit >= cdev->tx_max_coalesced_frames || + !netdev_xmit_more()) { + cdev->nr_txs_without_submit = 0; + submit = true; + } else { + submit = false; + } + m_can_tx_queue_skb(cdev, skb, submit); return NETDEV_TX_OK; } @@ -1998,6 +2030,7 @@ static int m_can_get_coalesce(struct net_device *dev, ec->rx_max_coalesced_frames_irq = cdev->rx_max_coalesced_frames_irq; ec->rx_coalesce_usecs_irq = cdev->rx_coalesce_usecs_irq; + ec->tx_max_coalesced_frames = cdev->tx_max_coalesced_frames; ec->tx_max_coalesced_frames_irq = cdev->tx_max_coalesced_frames_irq; ec->tx_coalesce_usecs_irq = cdev->tx_coalesce_usecs_irq; @@ -2042,6 +2075,18 @@ static int m_can_set_coalesce(struct net_device *dev, netdev_err(dev, "tx-frames-irq and tx-usecs-irq can only be set together\n"); return -EINVAL; } + if (ec->tx_max_coalesced_frames > cdev->mcfg[MRAM_TXE].num) { + netdev_err(dev, "tx-frames %u greater than the TX event FIFO %u\n", + ec->tx_max_coalesced_frames, + cdev->mcfg[MRAM_TXE].num); + return -EINVAL; + } + if (ec->tx_max_coalesced_frames > cdev->mcfg[MRAM_TXB].num) { + netdev_err(dev, "tx-frames %u greater than the TX FIFO %u\n", + ec->tx_max_coalesced_frames, + cdev->mcfg[MRAM_TXB].num); + return -EINVAL; + } if (ec->rx_coalesce_usecs_irq != 0 && ec->tx_coalesce_usecs_irq != 0 && ec->rx_coalesce_usecs_irq != ec->tx_coalesce_usecs_irq) { netdev_err(dev, "rx-usecs-irq %u needs to be equal to tx-usecs-irq %u if both are enabled\n", @@ -2052,6 +2097,7 @@ static int m_can_set_coalesce(struct net_device *dev, cdev->rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq; cdev->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq; + cdev->tx_max_coalesced_frames = ec->tx_max_coalesced_frames; cdev->tx_max_coalesced_frames_irq = ec->tx_max_coalesced_frames_irq; cdev->tx_coalesce_usecs_irq = ec->tx_coalesce_usecs_irq; @@ -2069,6 +2115,7 @@ static const struct ethtool_ops m_can_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ | + ETHTOOL_COALESCE_TX_MAX_FRAMES | ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ, .get_ts_info = ethtool_op_get_ts_info, .get_coalesce = m_can_get_coalesce, diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index e230cf320a6c..a2a6d10015fd 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -74,6 +74,7 @@ struct m_can_tx_op { struct m_can_classdev *cdev; struct work_struct work; struct sk_buff *skb; + bool submit; }; struct m_can_classdev { @@ -103,6 +104,7 @@ struct m_can_classdev { u32 active_interrupts; u32 rx_max_coalesced_frames_irq; u32 rx_coalesce_usecs_irq; + u32 tx_max_coalesced_frames; u32 tx_max_coalesced_frames_irq; u32 tx_coalesce_usecs_irq; @@ -117,6 +119,10 @@ struct m_can_classdev { int tx_fifo_size; int next_tx_op; + int nr_txs_without_submit; + /* bitfield of fifo elements that will be submitted together */ + u32 tx_peripheral_submit; + struct mram_cfg mcfg[MRAM_CFG_NUM]; };