From patchwork Wed Jan 25 19:50: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: 48279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456237wrn; Wed, 25 Jan 2023 11:52:24 -0800 (PST) X-Google-Smtp-Source: AK7set87sBJM5ZHleTFJdLabHKYMciOWCiS1Mm8CxWe2yDj+B77YT0AOsVHLSE4FH27Ht8IoJ3og X-Received: by 2002:a17:90b:1c8c:b0:22c:c0e:e9a8 with SMTP id oo12-20020a17090b1c8c00b0022c0c0ee9a8mr2569166pjb.16.1674676344545; Wed, 25 Jan 2023 11:52:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676344; cv=none; d=google.com; s=arc-20160816; b=FK10M8xvOGky0UFBhSS4v2HOJBSbc7JrrJAtDYr6S7jWh5cp2x1auaTcQRfrKAIyjK eZio9aveubl0y3X6oCBXbXbgEJhR3T9giEFvP1VfD1HcByFc6f0utryhaOtg33JpbOTj YvbfQpMDqJTv+AXql53oPD8anHHHX6x6bk9l2WMA5Z4SATSgmVqUitq/scnI+vfpCw5W Kpz9tsYL8CxEupscm/ZN2luvL/S4fh8HHaAf0IeCCDFMMKBc0UpC7DxtH2NNgsmRLoCL LoOBjxTtVrapjiwywJldsbmVa0j9gi4lEWL9pIxhZBdhr6mnh2Cx1dTvkXriFqaZBNNU QlRw== 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=mxWtntR87QPQtBcaxG7QqCrr8e8g6sulYm7WbYMis/Y=; b=tQaqlgT5Ne0oBJj/PqeP6t9bb6ae7oxSmbG6SJCaTRjf7vV0T5EQK3OdQpl/Yj/7Yu pxMDxclYHYfJf6pyYegbnO1icidaL8HVc+prwsgnaPfMx13esHTHmnWMwktKdlLSRt1Y eRJJ64giG+A4HS2W3/jo8uroq0Wh5fT6WZZj+V+BNKFoQB6TVK4vJ1pmHPyIOhUM7q67 gSmUA2W1mTze5nTTn39MKNnsIM2t7Yrz30ersWXMHzeSoh08ywQaZvRvFJctuwQhD6dk hb6Ok8XWGOidical5wUZyG0gWMQCdkfV0SYL1aljYddFeE7IRSle7Zxd3LO4n1Pf06zs mkNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=Wa6R4Leh; 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 x1-20020a17090a970100b0022692bdf6c0si2938027pjo.49.2023.01.25.11.52.13; Wed, 25 Jan 2023 11:52:24 -0800 (PST) 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=Wa6R4Leh; 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 S235543AbjAYTvP (ORCPT + 99 others); Wed, 25 Jan 2023 14:51:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235456AbjAYTvJ (ORCPT ); Wed, 25 Jan 2023 14:51:09 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0637458641 for ; Wed, 25 Jan 2023 11:51:06 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id rl14so47280705ejb.2 for ; Wed, 25 Jan 2023 11:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=mxWtntR87QPQtBcaxG7QqCrr8e8g6sulYm7WbYMis/Y=; b=Wa6R4LehTz4hL1fyn0Tgu/fMCKHyh1QO1mweKkity5p91CDaaEV5PERR3qAPxCSGAh mS5bkPYot/aFGWq7p4pHq+bNwx1/aH2BpNsaXWt+yXGOz63x88/JJ0gkhKoj4qja7n/Q z4XNkx/ING9Fc+3wYKLZgW4UolnLMqi8Xmp1Yp1aXeiz/UB0UOqRNjbNjgXJ5/IzPefm E3YRtHpM0xIVoC0zjPJ2KFYu/UgA9EIrY2FJzoyw8j6Bu2V9e8EWWLXxOvy7PoOtU6vt oy7qUwBPOAHvTFvSD6PchZp5CxiaaK4KRRxPYcWRwX9B9akyczvbsXMTpjNYnZA0MxUv IoCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=mxWtntR87QPQtBcaxG7QqCrr8e8g6sulYm7WbYMis/Y=; b=Qijl7lmVeritxKMEiMTe25NkTrnfP8NfPM36SYowsFz2EgUN9WSV3M3G/Kj1rVav4B OMkVQ2gEzcgZ2jqTNfShHVmm37mMthBgogTmMdpdI8f56QxIXO5/Xetg5+gRav48NKtU 22T5XjOXuz0ouxkL/oioWR0IG44BZqT83yRoxafzxlbfyHJ0n1hXtRlJoXpxqdwiqjfu guMmDYrpiAEj7xSVQe+sSv9L+KtI8nS60uC/lHLiL33QAJlQY1or/cPWZ5Mtt9HtaiJk 4U0/QbttGfvUNprNPlEiJYJAHJN+NhHYWSFIJuSwXuNNRvBkGAgTanPFT/8bQHS82gGX OhEA== X-Gm-Message-State: AFqh2krz2rK4lAdObcyiOhJTS0jODBky1UfECEBRxE1gluB3RVN40cor RFr/PTlvGi9pqr8kvvWoxZIAkw== X-Received: by 2002:a17:907:8a1d:b0:84d:3822:2fc7 with SMTP id sc29-20020a1709078a1d00b0084d38222fc7mr45785644ejc.77.1674676265435; Wed, 25 Jan 2023 11:51:05 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:05 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 01/18] can: tcan4x5x: Remove reserved register 0x814 from writable table Date: Wed, 25 Jan 2023 20:50:42 +0100 Message-Id: <20230125195059.630377-2-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025422744518579?= X-GMAIL-MSGID: =?utf-8?q?1756025422744518579?= The mentioned register is not writable. It is reserved and should not be written. Fixes: 39dbb21b6a29 ("can: tcan4x5x: Specify separate read/write ranges") Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/tcan4x5x-regmap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/can/m_can/tcan4x5x-regmap.c b/drivers/net/can/m_can/tcan4x5x-regmap.c index 2b218ce04e9f..fafa6daa67e6 100644 --- a/drivers/net/can/m_can/tcan4x5x-regmap.c +++ b/drivers/net/can/m_can/tcan4x5x-regmap.c @@ -95,7 +95,6 @@ static const struct regmap_range tcan4x5x_reg_table_wr_range[] = { regmap_reg_range(0x000c, 0x0010), /* Device configuration registers and Interrupt Flags*/ regmap_reg_range(0x0800, 0x080c), - regmap_reg_range(0x0814, 0x0814), regmap_reg_range(0x0820, 0x0820), regmap_reg_range(0x0830, 0x0830), /* M_CAN */ From patchwork Wed Jan 25 19:50: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: 48274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456081wrn; Wed, 25 Jan 2023 11:52:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXsBPeMJQk3+8vFzpft+5Dw02S1BXOYEfnIxlgPG9kJ4rfy03Nvf4LK4e3e4IC5kF7RfQQB6 X-Received: by 2002:a05:6a20:3558:b0:b8:8d2a:d37d with SMTP id f24-20020a056a20355800b000b88d2ad37dmr33112805pze.10.1674676324784; Wed, 25 Jan 2023 11:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676324; cv=none; d=google.com; s=arc-20160816; b=CCiBUP14ExLHSwZWpetlJF8E8bCA1glLARwVJdw9vZM9Jhc+40pRMTbKJut3pb72aB 3sMNwMsnTJcURcow91VZTSM4Dx+qZGDPs1cJ6GD5rUb7AHPhODVX+8KphQxBW3l881hJ XSKA0yyWCyaXmx9WPKBYHW1VqTnwZG0isc5Ep78JHH4eZMtd99+WNC3Cr9tHpR9kiy0N 1yEn3JmkXHEOsZMik93RxXisHoyk9JefR11RRBDTjzUaj9ymgmo8YkszZfk+FnwKqupT NdXiOMDJz0bP/grkvwrewqX5ngZ7sQLKL52V5awjM4egtJWvQ+kD5PthLiEvltGRYniq 5Ang== 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=49DCUG0FS6JWgdUUPYZw1kraoVWOTArEkjTgYYh32tM=; b=nPqIrBlcujO8wM/HwChvN1w0aTZpvH+8EThQh0fF685Bi2yKU7+uAuHFOS3OSa/+Tt HknGFTRhnYn6mt8AEEeBtlZ3NJl7rsmdG17gyHa0Mtu9YVASVVmOiJtClvMwQ9ZerYHR ytxKPPGIiBN3QIJa+hzxdjKS8u/u0LXK1qa4QBhcveqIetZ2UFrJlYh779GQgFc14pWK /8E8RF1Lyd+g70EeHBKPiWUxfUXWLdCMAMd7F2X7Zcx9b7EBuQRdWjgu9+8aBv5cgoyP nDebFzp1AfJ6ry1ZshNyekOT2Yp1b6b1MXpbl2VAbgNjnJo76ADkMj9WPRw5C/X+Bloy nFcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=T3x6Slzy; 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 h189-20020a6383c6000000b0046ff26f21f0si6058858pge.503.2023.01.25.11.51.52; Wed, 25 Jan 2023 11:52:04 -0800 (PST) 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=T3x6Slzy; 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 S235764AbjAYTvR (ORCPT + 99 others); Wed, 25 Jan 2023 14:51:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235501AbjAYTvJ (ORCPT ); Wed, 25 Jan 2023 14:51:09 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4557589BD for ; Wed, 25 Jan 2023 11:51:07 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id az20so50682119ejc.1 for ; Wed, 25 Jan 2023 11:51:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=49DCUG0FS6JWgdUUPYZw1kraoVWOTArEkjTgYYh32tM=; b=T3x6SlzyLZpgEUFsbjMT4SA+6d24DwTx7kCaFHQK6NA+tO62hkIfFFUC5i9HlGvCiY VO1SlLpwDGSuZfJJKYhiD+S0j0eVMaIL4ca2k/orI5EVJl27fYkjEu0M3tSnkawNjJlw oeAC6uAjZTp8awX53JRC3TjOu0yIv8IpLIP9JBNSM1Uj1sMjYltGPuojFVVBQkvtB8yw 1a+O+3D6ZFz/TbnfTmouKhL3+9tY8pUtJdA88EzMDdPGgKJB2JFoSR2q87wUwe+rc7m8 RKMkHbwEEsN1KvzR/ijJXBB5pKGtTjkjuE5L6FVGxZAslrQUiMn1yK9WtRFlnW30bePi 72sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=49DCUG0FS6JWgdUUPYZw1kraoVWOTArEkjTgYYh32tM=; b=a6EkS6+R9Zf67saKeBo4k4hKQE/ufykJdGD4y9XWWPD0sXMK9sqndC8Zakn7JFWpFH clAN8IBR64Gv5ynILiioxovgGBQ6nchsj3nbhOa8Ns+sJv3JWt9hEGTPqDTFqbFjlxG6 MkDqn3VCYxYg1u2+qngG5wLFj2t6wZDZMajNpQxPh9vE0VpScud7zEK0ifBwFJYhmdZm A6KH8NKO8F19juwn5WVPhQdRheup+pwdEBJCfKTGDNy0zFGRZUG4MfgdaQhcJrJ7UdPG uUTqGYs6JE0YnOGOj+YSbaTiYk0UjjxyW/dvxFl/yp42KdPE4EDTVZlP4tj8UdYOwAXh 5gSw== X-Gm-Message-State: AFqh2kpE2jStFZvpGk0NdbTCfCS/yYplHueRt8sT9IsrylCejKQDpBeR jeWOPIBOTaDtXivlmr1xbsvPqA== X-Received: by 2002:a17:906:3515:b0:7c1:1b89:1fe0 with SMTP id r21-20020a170906351500b007c11b891fe0mr33115318eja.65.1674676266354; Wed, 25 Jan 2023 11:51:06 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:06 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 02/18] can: tcan4x5x: Check size of mram configuration Date: Wed, 25 Jan 2023 20:50:43 +0100 Message-Id: <20230125195059.630377-3-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025401878981996?= X-GMAIL-MSGID: =?utf-8?q?1756025401878981996?= To reduce debugging effort in case the mram is misconfigured, add this size check of the DT configuration. Currently if the mram configuration doesn't fit into the available MRAM it just overwrites other areas of the MRAM. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 16 ++++++++++++++++ drivers/net/can/m_can/m_can.h | 1 + drivers/net/can/m_can/tcan4x5x-core.c | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 8e83d6963d85..8ccf20f093f8 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1886,6 +1886,22 @@ static int register_m_can_dev(struct net_device *dev) return register_candev(dev); } +int m_can_check_mram_cfg(struct m_can_classdev *cdev, u32 mram_max_size) +{ + u32 total_size; + + total_size = cdev->mcfg[MRAM_TXB].off - cdev->mcfg[MRAM_SIDF].off + + cdev->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE; + if (total_size > mram_max_size) { + dev_err(cdev->dev, "Total size of mram config(%u) exceeds mram(%u)\n", + total_size, mram_max_size); + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL_GPL(m_can_check_mram_cfg); + static void m_can_of_parse_mram(struct m_can_classdev *cdev, const u32 *mram_config_vals) { diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index a839dc71dc9b..d8150d8128e7 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -101,6 +101,7 @@ int m_can_class_register(struct m_can_classdev *cdev); void m_can_class_unregister(struct m_can_classdev *cdev); int m_can_class_get_clocks(struct m_can_classdev *cdev); int m_can_init_ram(struct m_can_classdev *priv); +int m_can_check_mram_cfg(struct m_can_classdev *cdev, u32 mram_max_size); int m_can_class_suspend(struct device *dev); int m_can_class_resume(struct device *dev); diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index 2342aa011647..e706518176e4 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -80,6 +80,7 @@ TCAN4X5X_MCAN_IR_RF1F) #define TCAN4X5X_MRAM_START 0x8000 +#define TCAN4X5X_MRAM_SIZE 0x800 #define TCAN4X5X_MCAN_OFFSET 0x1000 #define TCAN4X5X_CLEAR_ALL_INT 0xffffffff @@ -307,6 +308,10 @@ static int tcan4x5x_can_probe(struct spi_device *spi) if (!mcan_class) return -ENOMEM; + ret = m_can_check_mram_cfg(mcan_class, TCAN4X5X_MRAM_SIZE); + if (ret) + goto out_m_can_class_free_dev; + priv = cdev_to_priv(mcan_class); priv->power = devm_regulator_get_optional(&spi->dev, "vsup"); From patchwork Wed Jan 25 19:50: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: 48275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456082wrn; Wed, 25 Jan 2023 11:52:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXsxZk3KFJopPFGDutKcGNoE6QwtBcz7qP+Etv2R/a6gWcLcRcGnMl8tZ1xIveYVyhwEljWU X-Received: by 2002:a05:6a20:438a:b0:b8:6583:b654 with SMTP id i10-20020a056a20438a00b000b86583b654mr38322214pzl.28.1674676324991; Wed, 25 Jan 2023 11:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676324; cv=none; d=google.com; s=arc-20160816; b=dqedTmYEsK1/BCOVc/9XL7BZIhRrVdvhXAnDioNbL4nO+A+5dw0UE5M94gbIX1dBxX m1zhVa8KNmrB0MImZolhr7jtr4b9TCy2Nr0uHkLNMqkxKUuIIGN90WJMP+zacBd7inUX ASaM2s9bojarADDHxGbjpGTeQ5wE2YtZYW3+RCrC0qxo8arw03sTo3W+x8U9bXpORpQ/ wr4EX4vCNuWrzI9G9OJ6C8Oiv1TrFZE5zh8O1NLzBDU8XA9uEAnyEpxDMNysKUj1C5ds afs6wmPwzj8nQZ8B+EqxaTRv8nvwupD0iCLXP4pQ+Pbz5DEzz1hwlzkDbYFRc10PVjqe fYhA== 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=KMj657mIBfjdrk+ldR8wMbHCeTfGxrOBp5iVvF9MTxo=; b=iidxiAoI/jq0buwya7M9FVK17Iy7kv9oSfsCnvX7LwiiJVZObCn2UzveJ2x05mZcno BtvIgDAmcpys/Xk4ea4KC5zjzmL2z2wT6IA8lc3D4bRxPEpeoGpstV/uY02OqncVcqVZ 7aMsW9dx/T+ndZUF1mlAl2SwxYUAPjDGiX6xx4vtEiZgsE9PG5HAh/w/3VuvxeLCgPRE 3yRNPXIkMCK6B8+nAE9dNP9qrEoeZ7andopIpRQEbppGbyPhnP3nQzcxnI4VnA+FQ7Nf fQ+cJpYW3WG4JbxS6cyUCcFnFm7otN55pfsO+D+dmI1TmumWLvTop5FB1LSN2BkMeBGl PYLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=EFj5BZjA; 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 n10-20020a63b44a000000b004da9617dfddsi1187666pgu.210.2023.01.25.11.51.50; Wed, 25 Jan 2023 11:52:04 -0800 (PST) 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=EFj5BZjA; 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 S235812AbjAYTvZ (ORCPT + 99 others); Wed, 25 Jan 2023 14:51:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235541AbjAYTvK (ORCPT ); Wed, 25 Jan 2023 14:51:10 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA66A5924A for ; Wed, 25 Jan 2023 11:51:08 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id ud5so50647307ejc.4 for ; Wed, 25 Jan 2023 11:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=KMj657mIBfjdrk+ldR8wMbHCeTfGxrOBp5iVvF9MTxo=; b=EFj5BZjAFL8VzzzsMv8HLmG2IMjSc/WtgRSZNYk8gLngSYkDAB7eJ0/CCLwCKDaI8l uL+WH4aSlWtfVc22Wv6c8qjPoM+sYBY6mLCHZ7gdQcFQi5JeTiDfy4gtv54pZ7l6soPz gQqOL6bmeJip0Aj839wyJTatzTopDCW6oma33LKx2tWRNP7+NE6T1zYTt7WOKyxx0B8S qzEBX/o0L1jrYmx/lWwxUqgK3kfSiaFXGSFeUUUZxiIwHRvITJLCcZCjVM1HI8mSuqbW nEvIPqZQkpRs4Wm6SrBwyTohOrAoAXEcxldQwfcvvWBAV+gwQNILpSIq7q1/rASXR+v2 MGPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=KMj657mIBfjdrk+ldR8wMbHCeTfGxrOBp5iVvF9MTxo=; b=fpSK4wydGBLJIV7FQZOq8thLJ/wtk5Rf9vNm8hbcpm7XGcjBHzqHTtSNoKFtTxV4nq Ut32JejFC1HzVTZ1iJwIYirvYgMsgWWFBRMqQ2L1fS03BX9aTS5Qn8naHg8nk83izom8 2bBQ5hHcKkmvzecpK5jII5DQJCGSymy91etAs+dTq38NsD3M+QTd6zy8ETMofl/SSZq2 cQmFCVfoUBlNgGNGUuWAniUpNhWjx14veZcObA/5tSIwqfUEQj/bI18e4YjqXtkILObE qjGuXY+p0BALCNh6lrURaL4y3BRmtVuuiW6t516h0+qj/2r4jTq31Mjh4qKIXh/Ro+Qc gxNQ== X-Gm-Message-State: AFqh2kq5g7i1nbdugRjQXAVuhJFLe17rnvhO+1eMFNHSs9bxGufrCV0B adlV67w0Eg3JVI/W7YRJQLTPUQ== X-Received: by 2002:a17:906:644f:b0:877:6549:bb6 with SMTP id l15-20020a170906644f00b0087765490bb6mr27947745ejn.58.1674676267325; Wed, 25 Jan 2023 11:51:07 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:06 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 03/18] can: m_can: Remove repeated check for is_peripheral Date: Wed, 25 Jan 2023 20:50:44 +0100 Message-Id: <20230125195059.630377-4-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025402164025057?= X-GMAIL-MSGID: =?utf-8?q?1756025402164025057?= Merge both if-blocks to fix this. Signed-off-by: Markus Schneider-Pargmann --- 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 8ccf20f093f8..33abe938c30b 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 Jan 25 19:50: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: 48276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456084wrn; Wed, 25 Jan 2023 11:52:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXv9rebfTBTTqZ0rSKxOTyo8jabs6X8/lDCzq2dlRX8HFdpSlz99ZRQxm5o6mJHv8cRC+P+Y X-Received: by 2002:a17:902:e845:b0:192:f45e:4197 with SMTP id t5-20020a170902e84500b00192f45e4197mr44986484plg.31.1674676325157; Wed, 25 Jan 2023 11:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676325; cv=none; d=google.com; s=arc-20160816; b=bDtbsJ5V/KVOIdJLYgwNGuiXSCagILn5nJA7ZvYMZWFNoJnp0CNFOiJkXugej/nq6p EfDwUFu4TvQ/pDieOKCqULiQIuUR6/eufooUBh3zx1rf4wwQaqLhB8Eh45x1B98zyJjT yGCtYPnFevq0g15ieGKRh2OVEQEhn5e+9VERYZJYiPG//+6JZ18fHUYxVGV4Xyu2Za7j lfvAx7SKS4WLsV4ifHA1IaDfVC7qXjn1d5znAK67mirSE+BMpFvwesa2LP3J1u+ib0ms KsyHjFKGTcsQMN80uoxlXidreJHLDydLvHBym2PlSCTsaCtPpT3YZQcbqXWfcsEkBvFb 30FQ== 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=4ZXxLGpYkNLGcR4LovdInInPDGQW3TFLwetgUaPjssQ=; b=ctPQ1Q5WabKp0TjbaBPwtaoYqad6F1UTXqq3RprFiCZ00sXzy5mVnwuxaX5FYVRSle I8mEm1kdGkaXtz2Pk6ealQM0w06bY8/3aTwGJxxLDgyA730qgwfHI3+NI3NxysTBE9+V GDcMJh8DHQJyYz4Fa6NJ+jsiUsBOtuBBUqWdoXvOh7kylnsfdV+xLMAQ3ECT3D4rjOCE PuvRjy9OtLEOKBKnVhxxe+F1KUBH/gubK6sIUks7flT/Zo48tkA8hF0/ppRMab9vmJVK eSRIs/Np4pphfNOCWmOV7gp646c5UqzP+G+x51LyN4d8pOEaL0fUXV11kQGFQt7fvs9c fsrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=W23tRwv4; 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 q6-20020a17090311c600b001925d6fdfe3si7202424plh.142.2023.01.25.11.51.53; Wed, 25 Jan 2023 11:52:05 -0800 (PST) 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=W23tRwv4; 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 S235777AbjAYTvU (ORCPT + 99 others); Wed, 25 Jan 2023 14:51:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235339AbjAYTvL (ORCPT ); Wed, 25 Jan 2023 14:51:11 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A13622ED61 for ; Wed, 25 Jan 2023 11:51:09 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id nd31so35223ejc.8 for ; Wed, 25 Jan 2023 11:51:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=4ZXxLGpYkNLGcR4LovdInInPDGQW3TFLwetgUaPjssQ=; b=W23tRwv4tlQnu6fkwQN0QX5jysPCG+Kz3MLqdQNRukYPtFbsJNAHdRBnwI+8nIIOS3 SWLRhvPidwFEPSuwytVvoN+lZNLPna9ZbzZ2YZiiRIJlsthFLOHanspC1t8rFcxYz2MQ hncplSZ7Z+DF687j8Tn0jdT1waGrR/Wjbf25ruiTrzFPqQszyRFhFA1XMLqfarPVXnqm WVrZ5YB/3sCX9/QvcTdOnMzNsJ4aWekhryMF9T/AA8tlO7qIQBtNB1hw9eZiMaCtWehp NP9xE+AKDsGD4cGULtD0L9N0c8LOOgQdXmzhJN3iG4OthKEQviuL4dbfuL0peRTzS/kQ /sXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=4ZXxLGpYkNLGcR4LovdInInPDGQW3TFLwetgUaPjssQ=; b=QfDmWoQ+bLJeaqMiCWeJJRX0DS5qEAKBZAsi3mMjxVVypBlvmwAp7UWVwlBA8KZ00k L117Joss1xY980nbRkRci591NVutPxltGPmP3FuB4M4nX+G9hUeuh3r9oaZv8ga1rI77 7AR0FHIX+50J66HsyTpWlHxMaeRsGtEag6gdPTvP430oA6HL2ajGKPSnu5+iprNiJblC K13STvCtQ+ZZJlSvDTdP11DT7jVMHAV5aXLx2iOLxWk9kFDXn9fgxI4TUUYNCTvMq/3N WkSjo4swdKpv9eaDm+/nmbtTtMzcwGNzQg4mBieBtcH5JDtZiN9zq6A3Vdi5V+CR3lt7 F6fg== X-Gm-Message-State: AFqh2krCSMYdpBdRr/3miEXMreZq+u4lfZ7i7oY4DlFG0mElrftZTqUh Kjoh+ZsfTJhjXD+TUcRiR1hBEA== X-Received: by 2002:a17:906:774f:b0:870:94e:13f9 with SMTP id o15-20020a170906774f00b00870094e13f9mr35455819ejn.0.1674676268196; Wed, 25 Jan 2023 11:51:08 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:07 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 04/18] can: m_can: Always acknowledge all interrupts Date: Wed, 25 Jan 2023 20:50:45 +0100 Message-Id: <20230125195059.630377-5-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025402475305898?= X-GMAIL-MSGID: =?utf-8?q?1756025402475305898?= 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 --- 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 33abe938c30b..2df39dfa309b 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 Jan 25 19:50: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: 48273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456042wrn; Wed, 25 Jan 2023 11:51:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXuIj3aCkj99bNcNh1I3jbhDrDkmAh4sh3R06jiXTdw1UaQN0R62DS8Rjcm9E95G8JmWn/Zf X-Received: by 2002:a17:90a:cb88:b0:225:e9d9:63b2 with SMTP id a8-20020a17090acb8800b00225e9d963b2mr36492397pju.42.1674676318364; Wed, 25 Jan 2023 11:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676318; cv=none; d=google.com; s=arc-20160816; b=THZ6qwURLsGtd09sVQUOes3eUNEJVj6Ghs60sfjNFEuP2Y+PXMiltIPvD9lti1m/Qm mSJ+AuVT4j0I+JovxGRL+Wl3Fd6Vdl66mx3mmTY2CxJuYgjSh/mZ1pysYeTht4A5SzNj wlCYm5KE9PqvlJ3tWb+wC/h7rmPMkl9t4ZluijSRqmP7O9h7zdLnybo2rLCaVKHGLucf 7WGhdMX0mlpwnyFeva1be19FfGwRJsHiesqGeR/lPYNEmlbXiQUwgYQvSrFA+b+WJb74 RwVNmhXmF8DMqG5cMw724d4fDOZuL1grkr9aWRQQJfmcVuAR+qTL1jht27PGRi+qx4sW smpg== 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=EadAaSBIPgk+IhFGEGl7ST9vXs3rcnt68GgP+MjrSEY=; b=jlxuMnybCkMJp9wik1zH+8rPoBigBMNT7hbXv4sZ5Riuqwo2l8cPYJOvOSWG2fcdiA ayxmpkJlUbJgHkcNkFR2MEoo/EPQp34uupvNGuh/31Hq1dCMdMt5SyWpC9jhRTV963oB CCxWSviHMZxQN2CAXZFXvci56yZiSewY/MPteMrTM5lZGvr8FYK4aGnxwUchgLArefqb 7wgWBZ+rc3/5jeZUXQHmBrjpjzZoLDIDucZSCOqBep0k37r2+n1wQT8zJD6Pdv578xF0 KasG7uld9++RwPxDu4BfBLQKYe6jN/vKXR/YovLTqfwPmzsjnINE4SNA/dwlFGKY2sCX yrEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=Rk5M+PVe; 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 j10-20020a17090ae60a00b00219648ff3a5si2679126pjy.171.2023.01.25.11.51.45; Wed, 25 Jan 2023 11:51:58 -0800 (PST) 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=Rk5M+PVe; 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 S235791AbjAYTvX (ORCPT + 99 others); Wed, 25 Jan 2023 14:51:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235590AbjAYTvL (ORCPT ); Wed, 25 Jan 2023 14:51:11 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8899D457F6 for ; Wed, 25 Jan 2023 11:51:10 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id mp20so50561539ejc.7 for ; Wed, 25 Jan 2023 11:51:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=EadAaSBIPgk+IhFGEGl7ST9vXs3rcnt68GgP+MjrSEY=; b=Rk5M+PVeGH11E491B1aoDw/oKxxuhtw/OFCxkwW809SrHbXB/tOzU5FRR2xZM+QV/w 0MyCeN4A1JXtDVRtJdh2HDOtEiENmjiSxuSoWftPsy4X3sj4e7XRDNcTGdqpT5ePIvvL 97GZaqLNIlboRnu7swQMKDnryGNscRfU92ehuz7/tVVNPqlAQc5dNKceeGhd0qiM1BPa FFs+UIo7mF4YMnC5Dhx6ELs688A5LNM31fjLxipr7CdvNc3zxMtYjUjgtxMfoYyhhPv7 Nyz9yjQhPQHCcH5F3VL8sFBWBHW1hZSk6VgtzoSOhqI9SJwfO11reWw0nuOl4RrqmAWt /Ktg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=EadAaSBIPgk+IhFGEGl7ST9vXs3rcnt68GgP+MjrSEY=; b=YgLbkwXP3FOF55/USfaMiuYFHX+ykZXhGcDBbYGTF6nheYzDRfkG6unhGuPxsWruU8 dNIyXmycKfI4N7I6M6K3rmsPZruWHYwq1OZ4iHeTBWuUJXy5gCDcXiKYXe2QgpA5FF9M fdKWJvmYbB3qZnZc5SA1jwz8ue2OaOZJ3iZuwoXcU/f7IZ4jDxf1jeYAza03PSCZSJhI uBc0Z7hc/P8dPj6FbM21wDOaUYH6o37giiAomxKqzA8BD/UINWP2sc8JwRuXN4mP7Dyg yO2Zsr4XcXltyCBulSpHhF2qPFJMBuWsJFcR9NXaxgQEvrrzZLSm5Xy/TtpqukSMKY/F ZqxA== X-Gm-Message-State: AFqh2kpFr+Lh5FEHLyxokV3WJMEUkrv2Ex9VeJEizkbEuy3T/ud+tpWZ /ONl9Fu3IQWqdf3e4ZzWrsO2Jw== X-Received: by 2002:a17:906:ce23:b0:85a:4230:6743 with SMTP id sd3-20020a170906ce2300b0085a42306743mr33795342ejb.23.1674676268965; Wed, 25 Jan 2023 11:51:08 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:08 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 05/18] can: m_can: Remove double interrupt enable Date: Wed, 25 Jan 2023 20:50:46 +0100 Message-Id: <20230125195059.630377-6-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025395126525039?= X-GMAIL-MSGID: =?utf-8?q?1756025395126525039?= Interrupts are enabled a few lines further down as well. Remove this second call to enable all interrupts. Signed-off-by: Markus Schneider-Pargmann --- 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 2df39dfa309b..a668a5836cf8 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 Jan 25 19:50:47 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: 48282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456396wrn; Wed, 25 Jan 2023 11:52:46 -0800 (PST) X-Google-Smtp-Source: AK7set/az4PJnyXb5n/GCYpiA+0ne9HvVgurK3Pr5VILDQ1TPrJPGnbuthK2vATdBEg6tP1oxPkn X-Received: by 2002:a05:6a00:1350:b0:591:2ead:8eb with SMTP id k16-20020a056a00135000b005912ead08ebmr201872pfu.11.1674676366445; Wed, 25 Jan 2023 11:52:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676366; cv=none; d=google.com; s=arc-20160816; b=ZSc/Bbr+RMN7EnJNvQCyi4whfQ5GjukV756fMQt2qBIGD0Vc6Zcr5BCmkd/BzofYfU 7+YxbIinqmlFHOV+0pNe1/MgE5sh4irB0hoe5j4PP4wdnv4wIMo7SAQIOOj93+4WA9DE 7wwDkClqqlz4i4pzPG9U6T+jdsTWbCwT0yetGn8NNg2v/c3C1g1xzPrOrQ/CoWd5dcqh AWLPwkfGix+H8/PHYJdQVJQIueSz7mUJGcBB+pmD+QG2SKdBi6CjBXfBy9j+EzcYR2FQ JLLItlzdCfWAayaOLHLC4YMFa7Oh2yrMYfwE8AyK3jqIACnJxWCpFMHrkmkVXSimugX3 u9xQ== 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=j0FrFNu+fbId+cNGgF92T8X+IGYNGZVy8euZggQ4zwE=; b=qLSev+NUXUNqYr6zm3EsWhGUv8Z33KsY7T9p65xp86UeO8IAQWDrpajs9WSwR4Qg0W tKSw7ZXtqJhElTKrfcDOfQlgr3+QFvP6a/L7gkPoQMuZNzJfjKCtp1X9GX/Qkk4djFSo at63F/6jdqkdR84HtZOe84lQZxdsk6ylZX9oScNguAWTQVoU6hWpBAHDmKA7vh/RYeUY 9QefdFHgR0L+BHIDxGOZy7zMV+wnnKI2x7s3JkdTY5xqhddrmvkSMDKpu9eA4oHDcdhK R3ZRDQ+v2P/kO4QEPwqBqVoZR6PYxUugSLZEoTHVttVtS1ry/ktB25LR8wKhxsGSQceI oyWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=DaZ+wzH+; 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 m2-20020aa78a02000000b0058dd436a675si5965098pfa.365.2023.01.25.11.52.32; Wed, 25 Jan 2023 11:52:46 -0800 (PST) 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=DaZ+wzH+; 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 S235849AbjAYTva (ORCPT + 99 others); Wed, 25 Jan 2023 14:51:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235646AbjAYTvM (ORCPT ); Wed, 25 Jan 2023 14:51:12 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D38F45236 for ; Wed, 25 Jan 2023 11:51:11 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id mg12so50607039ejc.5 for ; Wed, 25 Jan 2023 11:51:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=j0FrFNu+fbId+cNGgF92T8X+IGYNGZVy8euZggQ4zwE=; b=DaZ+wzH+2Q3D+0BuJOX48IXhzvKiRQR1S83MMuxEZvJ4b7dw9tTD4fC96gpNbj3ihi btCoEOgY+LXjwaGffue1LP6BmeM7yMMNpolZ+1rPnmaJU09AjLxfSy/1uZsavutP/2GO 8FfFX5JIoKW1uN26KIrUOWloMB+KjElisT4eqkSHGXL+LYnGVvNcQpSQQDGJqsuKjnII rWMMUSAccNeWGtdK6MkDrVWQZS84dmeZLHImUH1Yzde0Q7fPYxcnSDNnl7eFgGNEJBYg VTWEounuOr9d0Bk7HpcFWcCODFf5GhGe7/ILoknpLkW64/pEvYOMHFlI0MIfnMtWzK6L 4Sow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=j0FrFNu+fbId+cNGgF92T8X+IGYNGZVy8euZggQ4zwE=; b=39nQ7bV98XdA7MkZVQbirKq+UxNMfiaY/jxRgN/hpTH/Xt2cs0xvF4WX8jdFSmOj17 mtSlmx2ycJJH5xfGvIIMlJjH5folZCH4kzy980EmC4hMH7lDvTfPIfxk40ZSG3tZTdpk ZaMLqO5vUONVVWRGW9PUxakkLTKxQ/0SwGJkys97xMJlyfbxnbSNM9tVcQtYEb/UxrUv eXyVyb17xH3VWxZ2FF2Q0/AO2hZw8skd7TESOu4aXe7stXpXDOO1X2xbgugfQPUITqvW hv7+IlBKf4hXkA/55wkZcKL0mMrCgaHJEH02FzMdybN5VnvgrRGU4oIRY/lgR9PEngJc +MEQ== X-Gm-Message-State: AFqh2krJ47gH4bwVWZhPywvG+DsUj32rloBGiQvVn7/EC0Ps1aynqukb ymf390fSiKrDAnU6hWuwTvZcuA== X-Received: by 2002:a17:907:6746:b0:84d:1c67:97d7 with SMTP id qm6-20020a170907674600b0084d1c6797d7mr41138473ejc.30.1674676269778; Wed, 25 Jan 2023 11:51:09 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:09 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 06/18] can: m_can: Disable unused interrupts Date: Wed, 25 Jan 2023 20:50:47 +0100 Message-Id: <20230125195059.630377-7-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025445943521141?= X-GMAIL-MSGID: =?utf-8?q?1756025445943521141?= 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 --- 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 a668a5836cf8..ef5ca5d37b0d 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1262,6 +1262,7 @@ static int m_can_chip_config(struct net_device *dev) { struct m_can_classdev *cdev = netdev_priv(dev); u32 cccr, test; + u32 interrupts = IR_ALL_INT; int err; err = m_can_init_ram(cdev); @@ -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 Jan 25 19:50:48 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: 48277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456195wrn; Wed, 25 Jan 2023 11:52:17 -0800 (PST) X-Google-Smtp-Source: AK7set9vBNoVy1SIHphq+HY3e93n9VsGzjcb9JGNo99DN7uRWwXl3dVqGRw+iFBOMSCWjd41zg6Y X-Received: by 2002:a17:902:c94e:b0:196:3650:63e3 with SMTP id i14-20020a170902c94e00b00196365063e3mr1650089pla.1.1674676337598; Wed, 25 Jan 2023 11:52:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676337; cv=none; d=google.com; s=arc-20160816; b=ipQGswE775sZgpAdb2boenzxzIDhZW3FGHzAGE6S5am3WeRzZ2JLOSQbpHMcM+sqRF 2H+A1YPU0P7rAKqnQBAMejkMejezgJLR2b3ciQxN5Nu9hK/aTcWJtK4iOCvu6DI/ROsF BomMvkL8piy3drY6syiUyMb+5eCXRKko+NxCexnsWxQPq59fmgVwqVzt98Rb1usl+41z 14mOvCU2XU/IEuxeHfPDBX4oQORa+qPps+l/LoEiAIFjj/yqjM5vozMn5/dQpdB/Fzmr VjR3YnlGjLqYY/n8L2UPrkiFKes7jJMkf65z5D0+F9HW0fDAiK4goFdgzPZ/w8ps0yVl RvcA== 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=yYyMkExZ6IN/MMZJH5eyzLSmSbOQmGlTSTJDGYdD9iE=; b=OUKg6/zzKsBy4VaSDQSn/rvbmh6WemqM/eWvdjG6jCwbZPBwY46EpROVSaWUx5qkeB 9UaimGNvkMQQr2S1uabOOXS2cAuubhNCO3ekpO6nCf7VZysUMKgdYgYtKXLgEUXeanNQ K+iumHNJ0TFdTcYXChNvcMW5oEZxU+sdz8AZa0nv/D0odnnPrQcgABs6nkdCKenH8AaZ wsGAj22N0nvcxOHxLFEAWdV8kF4byiC+vXQdpzsD/B4maVXilpm3hyAcZFkAWe8Xc9HJ YC8wRjwZk2sxgmxzXiKE476Gw9b/4F+VGAXCwliWewDLo23A3xFEO/yTwd0G+WFbymnn +RUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b="n/YOUFuM"; 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 f27-20020aa79d9b000000b0058003199fbbsi6030776pfq.63.2023.01.25.11.52.05; Wed, 25 Jan 2023 11:52:17 -0800 (PST) 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="n/YOUFuM"; 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 S235818AbjAYTvg (ORCPT + 99 others); Wed, 25 Jan 2023 14:51:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235707AbjAYTvP (ORCPT ); Wed, 25 Jan 2023 14:51:15 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D6EE59769 for ; Wed, 25 Jan 2023 11:51:12 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id kt14so50660745ejc.3 for ; Wed, 25 Jan 2023 11:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=yYyMkExZ6IN/MMZJH5eyzLSmSbOQmGlTSTJDGYdD9iE=; b=n/YOUFuMLzpqq1KdRJiK2At8DTnp5I75eAvwEu/+hxYgtIxUmJIaVmDpVghSuJIL+o DzUHlOx1qoZ/vXZBclIHHhfIt/ptnXZCFwFsyXJbPKiebK0TdZbPGeg6/iqpP8IKQi0x RKw2vJpjKi4arV1/RUmKZLscOA1YccgmBQppOKbFzdJlD6cecTX7gCWuQPvT5y2IU79R Ta0EApFZHJkL2ug1X8cu7Ch5m41hctck4gWEeKHKtPT5/chUcqpSAPrW2oetSCtu6jaX tOf4UhZKqwdQjmviSkFAT+fQ42EtlPs8fmhwgGZsJyhEyX+ZIStXS/XOHAZ6qqg+fKsj XgmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=yYyMkExZ6IN/MMZJH5eyzLSmSbOQmGlTSTJDGYdD9iE=; b=LtE31ovhiQaj/bXoQ++IXn2mnlgBtkMnLC8v5DjYUo5hjdRH5F6QhUljcvXFuVQJE/ eqWMmVjPVqGd9aOUQ+D2hG2Uc7UHJLSAPGRAyNqVGM773DdW0JRRKSkS4Hj3VVDSZJ9z YX9IZSZiCnIjRn7hsHKDABqoaDx1DcJgH4w5SiJtQGCs/2MPUr+z4ZkFVM0SfEWV3G9a AGVxuSRpcF9K1Oj8mdqWWq43c/zti3+DbK7suh5UiQuiPZVZyY/zjENmS7NuJ039PhNb ST1Dtyi/2fDUZfwOpcLntw8LxtjMYQZEAix/7d/1Wv8mh3ikw04O+Q09rs0Uxs10KC+G YMSw== X-Gm-Message-State: AFqh2kqNiYzH0EMUgeMFFN1KHqI0uR/kSbjcZp7NXK5e/fMbXYn59Emc LjsarOXUnswAoHe5azInnsM3HA== X-Received: by 2002:a17:906:6313:b0:872:6508:190 with SMTP id sk19-20020a170906631300b0087265080190mr37952541ejc.6.1674676270632; Wed, 25 Jan 2023 11:51:10 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:10 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 07/18] can: m_can: Keep interrupts enabled during peripheral read Date: Wed, 25 Jan 2023 20:50:48 +0100 Message-Id: <20230125195059.630377-8-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025415377740968?= X-GMAIL-MSGID: =?utf-8?q?1756025415377740968?= 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 --- 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 ef5ca5d37b0d..78f6ed744c36 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 Jan 25 19:50:49 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: 48278 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456216wrn; Wed, 25 Jan 2023 11:52:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXv40cmEv/el0rXa0Rsi41iWBhjMAA5Zi7065HND0ypm994t9ZYcwW0vStsJP1BXLIYo+UDd X-Received: by 2002:a17:902:ce0b:b0:194:9b4e:1c90 with SMTP id k11-20020a170902ce0b00b001949b4e1c90mr36397939plg.57.1674676340826; Wed, 25 Jan 2023 11:52:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676340; cv=none; d=google.com; s=arc-20160816; b=Kd50+NRqwNGt1cEpXZruDj1xp619UM1iMPKA9zalI5lc76lihGXrX/o81P1yfhc2yC QNZAABgh370i2FGid0uxx9QEWgaE7r9AxDyBTD3RAibeYIWLneuUXSlWNfuacXbXzi4C k6ZumcN20yg9nLEORpIVZPhxlJ7K+gVnduWACZm/nYFwkJ8qOkCSP8tyHdunQpIgR4si gDr1cXKyY4kKV0AtQji6dC6BRHTiZXgykQG3Uefv1DD7EqjDWmWrSeJaY273qQuljAOj egNp86UfxRmKiEulKznPsAvkvhat2hOrOyy9v6oLpAu2quoENSDXDu6JnFHo672B3FPF pLww== 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=gfSXrRwfX7neDYk1hRvs3xyY0TSXIO6TaVWNzYTFpJg=; b=Th3yQq+a+0xjaRW1bMOO8GBYHoPvYJuTkbdTrLrfYNj3QSSkXArwwZsh9/U+CUuoIQ PyTsJPQhv+xTQ+MIqYvQuezhEzhGZMotD/BSlIUD8Z8KL/Iy4DadBP8/ESozdDaYGvGg qoNirdPR0n5g5iAZ4/0mLjCTLl40CStyJokkvU0jhoyhLwTNxePwm3WIvVsJJAWjXWFS pip6eGA+kkPtZsYh5HRjFEMUvd4mHgIUIxXalWIjyWK5z5oN2wfDbi2vfJwq8RrwnOBS AjHkEItsjSVei45I+SfqlHJ7clQDDjpnRCIxwYl4IywZXPFje5LGiUOU5/g/o0MzLWA9 Cq/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=scmdglR0; 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 b8-20020a170903228800b0016efde92292si7206989plh.255.2023.01.25.11.52.09; Wed, 25 Jan 2023 11:52:20 -0800 (PST) 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=scmdglR0; 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 S235840AbjAYTvl (ORCPT + 99 others); Wed, 25 Jan 2023 14:51:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235836AbjAYTv2 (ORCPT ); Wed, 25 Jan 2023 14:51:28 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F18DA599B5 for ; Wed, 25 Jan 2023 11:51:12 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id kt14so50660844ejc.3 for ; Wed, 25 Jan 2023 11:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=gfSXrRwfX7neDYk1hRvs3xyY0TSXIO6TaVWNzYTFpJg=; b=scmdglR0kK6ToTgqQkU66fxS6xXrLK/8Z7gJfs3aCCx5gPWsq8u+p0MvW28eWc+aXq MJltcF7XaZBxK5C3wJ6SFp9gehas5nOhwaBIKXbUeE8u+3t7RkwpPO/YW9BY27ETA6D7 WycJ84fgNAy+8iKl0z3rRm/9dfBkZV0VZCFO9uhn5wpguZc8IYV/InkMWwG0070ipcPZ lCZSWQsFS6vbEdgcNOs+ostp36ajh0pFB2SqR207lb8G7CjzrP9QgItNXdQWFaDJ0bwY 7ssoeGE5MqD9EhcepVfA2k1lbeLCqSxaDO8P4n0mVBq8wsDluKTznWPsdoSM5Z2J7R7B QWHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=gfSXrRwfX7neDYk1hRvs3xyY0TSXIO6TaVWNzYTFpJg=; b=Qm77yU/JyS7WDpLf0QsG0/7Ten1wPQJwWo9Ua6ssNWrEhdd4YPKuoo3PFh+wHZleB+ z9y7BaOn4FQAlGPQxX+X+0xKJP1DBfPdarE9qdYWGem/e91le/3IZJDvR++8GJNiiAYl 21j1sN3h1g+h3VfqMuaFAiT5+PH4Jjke0PFNlorlvPocos7heWAqGhrumNmBNyiWzE6P Ul/NI6sUOtyO3JmCpDaw/zsf6aWxUAdAMgESaaehxEsdIWrZZWy5UEXbkVSTYPYgIzB6 k/IgPJmRdJYvtsTzkYM3NeIaFoSzqC4dKTmEgMnVRCMsndAfhDHAuOcVPeQxg0PDuiWw 7Zow== X-Gm-Message-State: AFqh2kqnQb4s7oBihV497+bCIfEsYJoR7OUVd4R9fR5QO70pZR9281nm QoO1Ct97lxTgZAT2jKV6uDRpEw== X-Received: by 2002:a17:907:6a98:b0:855:2c8e:ad52 with SMTP id ri24-20020a1709076a9800b008552c8ead52mr27221046ejc.29.1674676271506; Wed, 25 Jan 2023 11:51:11 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:11 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 08/18] can: m_can: Write transmit header and data in one transaction Date: Wed, 25 Jan 2023 20:50:49 +0100 Message-Id: <20230125195059.630377-9-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025418723167502?= X-GMAIL-MSGID: =?utf-8?q?1756025418723167502?= 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 78f6ed744c36..440bc0536951 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1681,6 +1681,7 @@ 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]; /* Transmit routine for version >= v3.1.x */ txfqs = m_can_read(cdev, M_CAN_TXFQS); @@ -1720,12 +1721,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(&buf[8], &cf->data, cf->len); - 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, 8 + DIV_ROUND_UP(cf->len, 4)); if (err) goto out_fail; From patchwork Wed Jan 25 19:50:50 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: 48285 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456536wrn; Wed, 25 Jan 2023 11:53:07 -0800 (PST) X-Google-Smtp-Source: AK7set8ho/Lio/wC7xx1zrWuQFrwjsEqLFt9fbrf8zJxQ6+Nx6QDC3hgXLkjUnmcemwWad3oyNCR X-Received: by 2002:a17:903:32d0:b0:196:2cc1:5082 with SMTP id i16-20020a17090332d000b001962cc15082mr3670143plr.67.1674676387318; Wed, 25 Jan 2023 11:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676387; cv=none; d=google.com; s=arc-20160816; b=lic+c76lL+JgjpIm2b54LcjQlzoo6lhybOd1bnn0DxwkWyMo5/aHGYh8Wx7BZypVJ1 41+PwF8WgAmiKecYNvj8ZRrZWXcqxbxty5FZgsXYlPPY7wuK1Mv1sNifGiHhFcRF84sN 5b3zlyfdgoX5HfwlY4I+6yHEJr7XJFVTm8ibC3OIyEJAV8GZUs5sA9n37fB1DbMOKwgh aWQUcG1Ux0CbT10f9q9C7jWgFb8lTV/hhguOg/R2eQT3KBBIf9bVmD+WnR7ehjPD/Y1p GqkP89cUPO7+Hjm9GP1ce8aS7t52ljaw0emLyh6IQuCVFqThePwQ/TlL2a2HwubnJrWo NL0w== 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=XmkLzqIv0SzR0RQcT/jEh3zGtNBbzIe5FRr1V1LtB9U=; b=R93t0NIkmOqNJKaNeZum2ejz3wHDPvaPSGB32mudlAaVRE9oSSnGDdP016Daltahc1 yHkFkqQ6H+BNPCTnwUSqGb5d2XgyfLAm/moJatKt8CkB3I4OkeNzmv+5OHNPoAYuLH0R gw/v0IUvsrIHbJ3pld2eVhUM+RRRHdniFxvJcK1LuCJpj2mfE3yWf7WFR7OtYYy3Gfxh 6g9mLbWPrrNjD7maBsDEn8rj8QMEXlFuESQ5NGO1m9CAdK9DL51Vh8w/2wCWcXAm79k2 BXLBvPBRDDYKhSGynOeoQKFGM/cmxgxIzcp5y9D69KTHsrNJ/EoKlo6T44HJG04sqxu+ xe8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=5WONJCrC; 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 k17-20020a170902761100b001787f1922a7si6274784pll.19.2023.01.25.11.52.55; Wed, 25 Jan 2023 11:53:07 -0800 (PST) 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=5WONJCrC; 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 S235995AbjAYTwA (ORCPT + 99 others); Wed, 25 Jan 2023 14:52:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235876AbjAYTve (ORCPT ); Wed, 25 Jan 2023 14:51:34 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4BFE59E70 for ; Wed, 25 Jan 2023 11:51:13 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id tz11so50685265ejc.0 for ; Wed, 25 Jan 2023 11:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=XmkLzqIv0SzR0RQcT/jEh3zGtNBbzIe5FRr1V1LtB9U=; b=5WONJCrClQyWE/ihgsINqQJJeHP698AB6PAaoNVNx1j1TOqpWWfRASMZGbfmHnSRDd u0yO2bMILuIYpUHelxnK/vS/2NDe4Uw9a7LPxUHYh4cAgabe0prxA0zdxaJxnHZxNJoN SB+P1AQfXeIA+JOvSJNNhzZuPvy2t7fC5LC7x0Vrq5FY8WtTUDd/JYKcMAYIBBeXgH4s EWOFBlOctvRnJVjETp4TZW4pTl811cyqrap7rLH7f4BHCMxNlfxKKc1sNKXZfV3XYrUj zMyZquhClnG8j1XzyB819tBdPWVQrNkDLAR0+r8XMnWdrDMplDBnKKLrkmh0ZxdTQIfU mu9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=XmkLzqIv0SzR0RQcT/jEh3zGtNBbzIe5FRr1V1LtB9U=; b=VnqAhz04fXGYNn1ivHl5WwuUog+d43z05se1CZ21D1wZheL5zPLdULnb57l2aj1+8O ajB/ysXlhiZ90fUMFtUzLNfsbBgLxLe+tWbG5MsFwwqY1OWmKFiso8G2OU59ZSa0m0gr Kdaw3581c3sGD6UTHtLZfUmO7VdI4lrngFuQ4E7BYvZERG6t2SXg4EpiOCz/6miBk1Np aDI4wdPPRhnY5FgB44UjCU8F3sSRg64yICz7k9VDpCUiiwbTemY99LAKnrjWrGfL739b ZrXV1zXqt68XDxpaahDVjhpXFSuJ8RwfT8k95cFdUSXVywDDVkzDOpPyHKTStPFOZl8o qrnA== X-Gm-Message-State: AFqh2ko3Dcl+SFKWe/gAGlRaS9w4IxKIQfs8Ut80uMgEIfy3RZSjAAEL db6IYlVR8VV3vrB5+7384UW5yA== X-Received: by 2002:a17:906:5acf:b0:86c:8f4a:58b4 with SMTP id x15-20020a1709065acf00b0086c8f4a58b4mr33921818ejs.13.1674676272401; Wed, 25 Jan 2023 11:51:12 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:12 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 09/18] can: m_can: Implement receive coalescing Date: Wed, 25 Jan 2023 20:50:50 +0100 Message-Id: <20230125195059.630377-10-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025467227363736?= X-GMAIL-MSGID: =?utf-8?q?1756025467227363736?= 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 --- 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 440bc0536951..a9d028ebc1f4 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); @@ -2056,6 +2110,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 d8150d8128e7..35aa3c70b0a3 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 Jan 25 19:50:51 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: 48280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456285wrn; Wed, 25 Jan 2023 11:52:30 -0800 (PST) X-Google-Smtp-Source: AK7set/nlZMsYorvf0Ze/qDfXx6i3jyBoitwtUUofiyy4pJxP1uRJ/RvdLy4hU8VBXXImweNWe+O X-Received: by 2002:a17:90b:4a0a:b0:22c:1a8:f88d with SMTP id kk10-20020a17090b4a0a00b0022c01a8f88dmr4411624pjb.40.1674676350723; Wed, 25 Jan 2023 11:52:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676350; cv=none; d=google.com; s=arc-20160816; b=tsnlgWA2R/Jxw+BJXQIWMiS9hBoKmgKJWjUNp/VbQM7hYXi34aDB9fVBmLJnUbW4/b VwJ/6GlfakU1NAztzSyOvtgDQC1lEAxLC2CqkC1bkpCAARbq2lgp/Ys3X2PdV6vqKUrs xqpCyrdRZQiurH/hFwiM2fdy9/RGWg7ff6Q7MEx9qizfu5NwB6WsHoGw9Qkr6AIoiet1 5nOmENkXwojLpK+JEbTtq9RWMRYyKNoh5w7R8EvdNwlzLrXh6NzG7FAzFWESCae35q6H ttQrC7hUEjtb3DtnQdG4+jV6NLRZwJcPW+Re636/yNdYi6lB4cy7gluQi6qGYzgL5HZI D0hg== 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=DaeIa0Og32Nc18yUwKazkfXKROUGY5JQszAI0CKb6Vs=; b=Q/GgJlAktAKQSVW8IpQAEK3+4AjHl44YqPkTPwCSA3Lizd4Ix49Etb8PDT4xm9zfnM BJZBqqL3bPB++jxY7KP8z6pb7dncYnXMyMRSkP71osIQOx/QEXaUvfbirBHAE8ozHrYP NeH/3TRv26zXMfW1BFrLj7eQ3PqdzHfYUnn4NbIgdDHoMMOyQv42KjORtnGMez+GKF2B IFzwgE+PY58hR96q+Nl1yr8JbUqOAHQSbFAA7QuifEwJIjSApiKOyIuqYpcnMODdwHTO ss0jR8ziEr5WLnc0nqsMcqF9QDazlmA7yPgNkaCvc+9TVYQzwTUJ9xD33YSwWBly1YRL RdQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=lS9gGYHu; 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 mm5-20020a17090b358500b00226e2321ea3si2803971pjb.157.2023.01.25.11.52.19; Wed, 25 Jan 2023 11:52:30 -0800 (PST) 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=lS9gGYHu; 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 S235954AbjAYTvs (ORCPT + 99 others); Wed, 25 Jan 2023 14:51:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235859AbjAYTvd (ORCPT ); Wed, 25 Jan 2023 14:51:33 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A612F59B71 for ; Wed, 25 Jan 2023 11:51:13 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id mg12so50607484ejc.5 for ; Wed, 25 Jan 2023 11:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=DaeIa0Og32Nc18yUwKazkfXKROUGY5JQszAI0CKb6Vs=; b=lS9gGYHuiuM/w80eo3DAsw58dwrFA1eksEYp23X8XUfPEeV/wEuepNa0Ug7REjGdIX 6ghKhgpFh4fC3Gebtv4AvJf/eKCY0CGjBtV4WGKq5Kr5/zCs4CkjhV02ptrdUqYu2+5W 4gS3Yz/H+bykdw2oJyyrUUS2gThandS/vGkFUu2A+gwPdzC7zqokFHbyimnRT+8PJEt6 KjkeFwCHoCZkKktBfk4Uje2HNH+M9Tz9gfULOSMQeOZVf+NFSzOkCQTI7/yggl+v0tyA L3JNNDcOZkyCoGWI3ULBIPxowk8M0tb6VYeLbgdFcVCxfSgQer2tE+MFLs1zZLHwYojk LBzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=DaeIa0Og32Nc18yUwKazkfXKROUGY5JQszAI0CKb6Vs=; b=zh8tBFK6qSuGjYDmOzb3G+LQ4LoJYDuKcRHsyTcX+0OZ6WSBbkfQXL3MH4qDrWdCZ9 8IbyRfREAfQE41yh2XvnrUjAoa0gZN11DhnC7GAizpetyNiMb8YBJDP9qkyom5w+Shko QnFz/ozls9feSoOCKIt6agZtlJXxlsQNLYsRP/2icY2Aty6iQ33vEELlmw8rkvMVj9qb 3RvFEOjKPIJvw4yl6AJjt+Bo7Utwt9TTRKESYzkBZ0gpPiWzPbqifoW1pImf36pLjgTz G4iEMXUs9l834ZWLmr93GKI6tHPuGuReqbQscdNM71mxQCu7dKm+oEqkGo1oj7lvtZcB 9abA== X-Gm-Message-State: AFqh2koNDrlHKuip/2GqAIRcdlajXlWgHpXE7NO7ZLzzTUIGs4Grw33q I7HLIwWKrwIg1jcFAZQTOqWsiw== X-Received: by 2002:a17:906:b081:b0:877:7789:765a with SMTP id x1-20020a170906b08100b008777789765amr27140345ejy.16.1674676273265; Wed, 25 Jan 2023 11:51:13 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:12 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 10/18] can: m_can: Implement transmit coalescing Date: Wed, 25 Jan 2023 20:50:51 +0100 Message-Id: <20230125195059.630377-11-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025429271576932?= X-GMAIL-MSGID: =?utf-8?q?1756025429271576932?= 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 --- 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 a9d028ebc1f4..31a5e551ebd9 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 35aa3c70b0a3..0721faae7886 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 Jan 25 19:50:52 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: 48283 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456407wrn; Wed, 25 Jan 2023 11:52:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXs7co6AslrGJLZ1DwKN6KnJe2JFIuVp3VDTG9epj97G79BbASz+IrCW3my6p4yE/mKmE3Yh X-Received: by 2002:a05:6a20:6f06:b0:ad:5cde:8f05 with SMTP id gt6-20020a056a206f0600b000ad5cde8f05mr30957174pzb.37.1674676367657; Wed, 25 Jan 2023 11:52:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676367; cv=none; d=google.com; s=arc-20160816; b=qtHINMsZnYIgf+LDxUhwJp7UgwrOBL+FAiRLeOSpP/RHgMnwSbKAortYmGq/AfSrv2 +LooYKJ9dScgubDQZ/RLy0Sd1f78pVMMKVSr4nMcwfO6KfFJJYnZ7IyibwxwvrwL3DMM 9VjSu+bxuPpFQtIjU+b0kiloLSuMT8T8OGZAls3cjV/mABtxgcZBliEmUdD+mefQzeqp BRqReOjGeI/aBbXV65h+OyIpxu/OdzTfP2K9peJM8gHY7X7wjwM/jaj/p5t3S1Vk84/s qn/Odg36mLfWvYA2ry+qqpaTs6wxz7IEVVK1igeM8v+DV18E/2pSzIEkFY/xSfjXOlfx kz9g== 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=MPZRbcn+ayOOx/787tD+d5yfOpNzt8F4/+0TUH3wcFQ=; b=ImXzXAOqNFElzmUhq2KfN1rVkrCcmYCzIoz1oeIWNUNijt/4fJgZ267bJAltPXPezh qz9b+nmDEJv62XspCigx9nT3t7g0Mltg9X+aoSHmNkU/H3H4jGrPUYib9YmFK2CBRqOj HqHeD48vaDFDuw75dxzh2/mR8uxyQxpp3ulfzb/KawsyMvhhM9o8CbzkwcVAdlO2m9qK 9TVmMLX4ACbl0x43Yp+IxTGENo+W5tkswrT7qfD2H/zB8vcev/KkJGW+jQq277b5MeNP LkZrDPY6kveYaGGHukGqQ8y06M6s5NzHlAKSi0QRcm22tiHp8NBoxzcUAHxBiKLw9meD bqXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=xWuzZuT6; 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 o18-20020a656a52000000b004ce20c32635si6888415pgu.844.2023.01.25.11.52.36; Wed, 25 Jan 2023 11:52:47 -0800 (PST) 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=xWuzZuT6; 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 S236082AbjAYTwH (ORCPT + 99 others); Wed, 25 Jan 2023 14:52:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235913AbjAYTvj (ORCPT ); Wed, 25 Jan 2023 14:51:39 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 885365A801 for ; Wed, 25 Jan 2023 11:51:15 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id tz11so50685462ejc.0 for ; Wed, 25 Jan 2023 11:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=MPZRbcn+ayOOx/787tD+d5yfOpNzt8F4/+0TUH3wcFQ=; b=xWuzZuT6B1uM5aAUffyZgQxOrYA9VusXutUVZ5QO9TF9e/Kpe3RBVU6cJlxUC55o6D SBX2+JVmpDG5pOrITnrCYKJna+28SxE1qCr4VOtrrqrfEjPTHk0SCZ/vGYgU0gDW4m3q 6LImlYw7L/6+NC0oFFQSLfDDTnRzKaIQ+IVYI0VbdC5xnaMmV9pllfI2Zy9+Je/2Gjs9 jIj2HJ+fa2SDWgnnDwnEJu3OJ8SO+UGfVMj7iXLIlG5IvL3nVEqUBiyWA+A7fDA4cija cb1cloQSJVBlQAnzyF0QiTEjOsmzwkgZYiqakQmAtEsNjMw3y0IOibU7u5SjKMMWim72 NzWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=MPZRbcn+ayOOx/787tD+d5yfOpNzt8F4/+0TUH3wcFQ=; b=7EDd4wHTbb+tTbSsKuDPc1JPmUVQb1EFpfFLvxjpSwZgzh0mypPZIUEkE0S63qrr+R sspuqQ+fYoeC9MRT+6EGKOkWbt+RDS1YewLMfOnUMZB+1w9YZTU0QyLgrVYOTem71Fdv L46chdd3Qd7ve7kcCXnNe3bCIlm2EBkzhXNtKgdIentXf3HFjofNtrbUNJoCCHvx5frj UvJv7qxu0zYdWn1Zs5oBzBhSn5dOfwd69sv58C1DlefedrCiV1PUiiZe+A3MpmaHXb3E XIqX7BoZwaLKAM6i4hOKf1FDTbMUj+8BQ3FuhEbc7pao8CrR6o09h5E1dR9UqEdZ4IVU vYNA== X-Gm-Message-State: AFqh2kpKC0X+jkKyF+vqdZO8yJoy5b9ol3LubAZyeUdSfMvhXNUym/a2 CFiRxMRrnbY2H08horAgvSyLOw== X-Received: by 2002:a17:906:514:b0:7c1:1ada:5e1e with SMTP id j20-20020a170906051400b007c11ada5e1emr34079325eja.26.1674676274128; Wed, 25 Jan 2023 11:51:14 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:13 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 11/18] can: m_can: Add rx coalescing ethtool support Date: Wed, 25 Jan 2023 20:50:52 +0100 Message-Id: <20230125195059.630377-12-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025446764482422?= X-GMAIL-MSGID: =?utf-8?q?1756025446764482422?= 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 --- 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 31a5e551ebd9..35c38c230a00 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1935,8 +1935,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 Jan 25 19:50:53 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: 48281 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456336wrn; Wed, 25 Jan 2023 11:52:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXvxb513dmUNuZHlMgfo21wEAWFmvJvph1NX1NNI+2R9OQSBln5WnT346G8ku+DdYFK00eJA X-Received: by 2002:a05:6a20:d394:b0:b8:9922:dd2a with SMTP id iq20-20020a056a20d39400b000b89922dd2amr36353745pzb.57.1674676360101; Wed, 25 Jan 2023 11:52:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676360; cv=none; d=google.com; s=arc-20160816; b=t0AgICkcO8vXe2/qS4y1W+5F4a0244ZVImoxqaQf2iiQiT93xCFirifBgv+ADi0e29 oNK850enQjVfNOed38N/EbkkFW1V1mBFOJ2kXfzdt2848UYf59iaOgVapofgsPkTn0W/ lsibP53oDeATQsXsfKhZJI5wlHr12iSxXCRv/4JSE7I+dLGhHq4K3sV+GrnYBhCBy0LM +hnipyl8re5HL5rSEqHMbDl1mRc9YBflcjQA/xBzVJv7SiSSeKyBXeZoOQTivHT6RH4K 44cNfDdwwo4Bapeis6Us47LOYfHNVWYg21OEAOkIq7MCA2beedj52Q3ljReHwcKvyNkA VnoA== 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=QfommV9SggPT6ODN0C3xf43Tcngh6JSfHsK3JHWDVGY=; b=ZqqgWcj9NT6AtEEeWldE8Os0eG7Ok5dea9WXkhKYT9mZKRsIKGDEIrDPsO3Ul0XmWs rIjkYUFN7sO+ivrkCPcS5VAw9IEhfYuxtSLp7WTsC/+k5J2Of1zMvdvc3/Zli5UlA00J LpAVaQGNful6oqLX83Tq67Y8lTbn82VSIvaqqV70Lv2ocl6e5CvHi9idIG33VbhOiJ5l ZcyelZmULOOS6Go8yxXxyqHvKSC/iAdL+s/tyk7wTGGNRd7XJIDTisJeaSTMTJQwmPxi fUnh150oyRfm3D2WEgIYgm9ErKfYp7QtfamHWwBE8UFYUOOsXlPFA+dmGTlRPdOTxtcV tylg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=EAVvGTpO; 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 j63-20020a638b42000000b004a227152324si6281005pge.839.2023.01.25.11.52.28; Wed, 25 Jan 2023 11:52:40 -0800 (PST) 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=EAVvGTpO; 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 S235844AbjAYTwD (ORCPT + 99 others); Wed, 25 Jan 2023 14:52:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235707AbjAYTvj (ORCPT ); Wed, 25 Jan 2023 14:51:39 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B1EE59574 for ; Wed, 25 Jan 2023 11:51:15 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id vw16so50582904ejc.12 for ; Wed, 25 Jan 2023 11:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=QfommV9SggPT6ODN0C3xf43Tcngh6JSfHsK3JHWDVGY=; b=EAVvGTpOTDJ6cVDVcMwO07k2FmJrvWy9qroV4RCQs5igp0Ik0sNwLhS8JY69vx4VwT 1DVXvZcphS914vwdO2duYYrcf9NbRNHO9sieMavL4Ezetq648t2vET56QK6YHnABqkD+ 7fA53W2QfBWIvQmTHDf/3EqO4mQR57dKS1rEDiiJKmGwC351bVu6u2iUwTZXjd4ZWbGI 8qDfHOh3tlXkrRCkFLseE4+KDTi0b20ftS3nZt/tF4F790dzrHfq/KK1F2UQobfbZSvj qPEZVoCxVEkwp8ycQQ0xCpRfrUnZ/EpHW2Ak+YWXbSCQyXiNzeGWEZmW8Ux5z8luTRps lnVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=QfommV9SggPT6ODN0C3xf43Tcngh6JSfHsK3JHWDVGY=; b=lse0zKX/2aQ4kGBiUZ0yAVEgaVD99uAZ9aey2BiBrvnIz96wWW0yD2vwHf4eo2elb8 hINwq1Vcl0nNCeEX5cIqWINqxytnzNPVCJOkHw5ZHRvhUZGHI5wEx1Hm3AwrJ/PeakdV eO5BrIk5/zPli2hoMAxJTkXZYRtf+1enoVrm0ywpYaGmmVlgRu55OZ4GxBxOVdCY4taA eW01r+A6+MLTEklssQj0vAY+C1sKU7rlcFud/Hl95o7pURhxg5lDwr2r45TbFET+e1kT I68quKqGDMuZGigwPaz3TaZJWUgTApEj0WHwTJmHrz3XUTR2RzB1h9j8d71QKIa+IB0O mQpA== X-Gm-Message-State: AFqh2krmDb+oQvUoYTzQwnnWBznUnPaNbWWcu/3Wj8EejK4/orMcHEfN ZVWW7y9AM/wYbkUOYd5JI+y2Gw== X-Received: by 2002:a17:906:9c8b:b0:84d:ed5:a406 with SMTP id fj11-20020a1709069c8b00b0084d0ed5a406mr47950330ejc.14.1674676275056; Wed, 25 Jan 2023 11:51:15 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:14 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 12/18] can: m_can: Add tx coalescing ethtool support Date: Wed, 25 Jan 2023 20:50:53 +0100 Message-Id: <20230125195059.630377-13-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025438944896707?= X-GMAIL-MSGID: =?utf-8?q?1756025438944896707?= 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 --- 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 35c38c230a00..9d2345f52ddc 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1944,6 +1944,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; } @@ -1970,16 +1972,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 Jan 25 19:50:54 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: 48284 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456475wrn; Wed, 25 Jan 2023 11:52:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXvIbN76f+SmLrMN8gskwwk0lX0hq0RwscVpsvmyyJs3BcwYr1tYwduRsJpv97SsNF+n0NNr X-Received: by 2002:a05:6a00:1c9d:b0:577:b52:4ec2 with SMTP id y29-20020a056a001c9d00b005770b524ec2mr30042471pfw.29.1674676377414; Wed, 25 Jan 2023 11:52:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676377; cv=none; d=google.com; s=arc-20160816; b=VCdpv4Jm7YmNIq3tL17yDB0nX5rVMrVPiAEtqa1i3olXhJQHyjARmSbhiv8hBJ3peP 4PXYwTqGHQPiXf45JHavnac9beED9dOgYZyTtgN89Iy1ZKvvVhuS0jtE7bm84hHShCZY xiDiNO3cy0n+1Wj6/C+qhMsMTYHpOSDPpc/yYpxRWYbMD9ctm5oiD31v/3twkAikVOY5 PBPXiARad8Enr9ILapNqsGUyWX+w5ZCuH/78NohkroNuCw27lsZNl1VAA6HPyNGce8DH B2mtu1TZjtDIE/U0Z/2aTFMKB5glAdVKLrSGwro+2po2uZ3js+z23sPpJWRj1P14pDYs xeqw== 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=w2lrVaPRiH6uq0q+cTr4TOtwHEPWA0Tt42PRWTeXIWc=; b=M/jDiaP0Qon6Pz5UVOh/RBGo9ea+iOPvSEPHGe+R/tirpfW0SDo+lDDw75BGyWle6n NUaWX2+sX7ea++4lxJd8RVFg2IIEHMh1zXMA8LSYeRgsSJKKn0zS8mml0L0vaB3oY52S LDhB7FwfosVMwvQlVDXKLn8OJA397MiWDQzqkgI43BPgmNGnCoz95aF4yRaaOAv9qEda wmdFrFy8FsGW2nFaO7v57VMNfDuC+kZnL7MsiZM+uF/LwKouro/NBcU1rawDYQTFyjVQ h4YF4yAfRxHuZP3xSTgaSppYhBgKzECxJVqByOEA5AIzpJznpK0KoyNw9XsbLKw69ERs 5Ebg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=11ddGa4o; 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 s9-20020a056a00178900b0056cb4662b9csi7313284pfg.16.2023.01.25.11.52.46; Wed, 25 Jan 2023 11:52:57 -0800 (PST) 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=11ddGa4o; 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 S236135AbjAYTwR (ORCPT + 99 others); Wed, 25 Jan 2023 14:52:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235958AbjAYTv4 (ORCPT ); Wed, 25 Jan 2023 14:51:56 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA52259E71 for ; Wed, 25 Jan 2023 11:51:16 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id kt14so50661326ejc.3 for ; Wed, 25 Jan 2023 11:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=w2lrVaPRiH6uq0q+cTr4TOtwHEPWA0Tt42PRWTeXIWc=; b=11ddGa4oOpWRyKolQ6bWHrgxflSd66PqlC7gEHln8u92cm2fHxEDuXQnsx+GplqmBF O98ig0tyA/L45rH+GuTFcWtfDbEgD+DIofkW9Yv1Y+p+OYVE99xlTnoGYHRhsubVM9GX APR/+jZdxRoEsuYLoMfCHDXU6glernrMuzuGlfScC5AhjWtCCeLxyiYzKbAcfGPJkVvX iSepxLaqsVnFAx18JoK27x1Df0y9aBmXMPBpaHeWdb42GA45LZopnejDC7+hFCzos3m4 fY+YAr3KM8xWcfNMQEp72xGoUmvZDhbFiwST4iYRWaSG8cdvRHWctuFDeizm4+O1J3Vz dADg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=w2lrVaPRiH6uq0q+cTr4TOtwHEPWA0Tt42PRWTeXIWc=; b=le3a3I2hc48wbZku8t3datfaZFA+3WDqgLBO/Uoo2ve1RnK/R+hc92FGBNEywKHZgI 2T01eWwYhhQfTOzBNsXp85tJ0thHNIYh4BitLS2+683U/4hQX2lE5XCOJo6wiw83iV4u FGnTjkuIsbYmKhpsl4q+9zbL5Tl6n1Ni8D8YBb6R5oxe4ZQjEik9ULVAOV/ZLYgJZGkC sloy+OnPMy4ibhPvZs4D4j19Ec2xeaIc7tGbflveXQAqBfxXMGT7HTyw9y6pN/yqlHGZ iJalGTCoM1VD9da0Joprud4A36RypgG6oVe0tkNiXxHcUvQXvsGViHkcnHkkqsK8vAT+ 7umA== X-Gm-Message-State: AFqh2kpdQwy2Wv3Ybnjo24GztatnonJhuuuio6o+vKJ/3FhhTwWLqQ7a BVz/CDSxdUlTgFO3vyZkw30e5g== X-Received: by 2002:a17:907:9548:b0:84d:37d4:7533 with SMTP id ex8-20020a170907954800b0084d37d47533mr29992408ejc.0.1674676276031; Wed, 25 Jan 2023 11:51:16 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:15 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 13/18] can: m_can: Cache tx putidx Date: Wed, 25 Jan 2023 20:50:54 +0100 Message-Id: <20230125195059.630377-14-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025457201880320?= X-GMAIL-MSGID: =?utf-8?q?1756025457201880320?= 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 --- 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 9d2345f52ddc..83ffb4c0eb4c 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; } @@ -1764,7 +1768,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, @@ -1797,6 +1801,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 0721faae7886..4437085f63b8 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 Jan 25 19:50:55 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: 48287 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456604wrn; Wed, 25 Jan 2023 11:53:16 -0800 (PST) X-Google-Smtp-Source: AK7set+IqHKzkEGAcCyljVrXptRSEKBgl1fuzoiDVyd5B+GqEk8BUtscDKHWzK8jMRadK7xFz6uG X-Received: by 2002:a17:903:2344:b0:196:11a8:ebb5 with SMTP id c4-20020a170903234400b0019611a8ebb5mr9571275plh.2.1674676396058; Wed, 25 Jan 2023 11:53:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676396; cv=none; d=google.com; s=arc-20160816; b=tFp1b/VoOQXfVMfuKKJW3UcOcAeA3ATcMVjOS5jmplDZRVpYpfF/fwQvfLrzQChxL/ nQTGS/4tUNXiws57pnyUh365XQtHRnp96SoFxJS+Kr7L/XIFFMSFnFY+BRAS39C+ts13 76fGCTHI5kCZFamK2DlIqzL3IXSI8k9QTIoqftk6534RxlRw9vL3kP8xZB4f0lvpqPcJ pDiaIq+grTOcRSVlaSVZsuB0sdWTDaEWl1gVCnMe1M2Lv8k6uqtaa87WF7ip9aMqZEoA +UyV5ZheXTpWnVMqqQ4mGGjkEuA8vwRf8odO0CM2Si6HkzingMiWjU7l/AiLPRUQBly5 erig== 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=fZXSe+W5cVBmHn39qBn1fgW+vdfoWT/J0aoyP8tJEY0=; b=xzL2zUSMFzQwrAio4jrUaADuquRaunx2G47ITzopfBT6uka5UVuqa6Kmj4DxgTScju x7k6RgrIoUsV0LBpDyvRt4WxoHYiCcViTTEaBkXksJlpIjOrhmWttRbPQYvOa8FWnuy2 bF0KywU/xcBTIOnTnXJE1nVzxNTFCPldQX9zOYkOELZgCzrpDR9yEZRSGHR5WihrsBJc IxrrOm8/z1U1oJU1gO5cyhfczBeHc9NSWZt/DpZyg4c7yMN9opF+kWOeO6PDpmltJgwn MQd/MyDRDnB3qtkoMtaXxdO92RiRUFym/4YxmyO2XjwVm0TPDUrhzal6aC9I4uGvEYmA xujQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=lR6BNV1O; 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 m9-20020a17090aab0900b0022726215f21si2799778pjq.179.2023.01.25.11.53.04; Wed, 25 Jan 2023 11:53:16 -0800 (PST) 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=lR6BNV1O; 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 S234990AbjAYTwq (ORCPT + 99 others); Wed, 25 Jan 2023 14:52:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235988AbjAYTwR (ORCPT ); Wed, 25 Jan 2023 14:52:17 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DC6959994 for ; Wed, 25 Jan 2023 11:51:19 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id az20so50683263ejc.1 for ; Wed, 25 Jan 2023 11:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=fZXSe+W5cVBmHn39qBn1fgW+vdfoWT/J0aoyP8tJEY0=; b=lR6BNV1OIuwBB1OtVeSeyzQKeOVrwLmnMiMZpVQY1YkgGIVhhkirqCRuM3G6cfvudo fOVFqz11nViGbdyUbD2nJPk9c7sTwO4CyM/OVFH7l8pbpXq8HXwPMomVU9RzlT7MuClU RLCn8KIif77ABBpVD8z/Bpix/sMvEqVoIGSA6tt11xDjHng7UQ/jz48TIKpoG71VAS7l RC4CW3nBNewPMG3kDaM41lHzWgwSa97A4SZc4O53feXtFxG9a0jAW2MZFWopXC3EKWrT 1MJv1LtHOVE4ddVzs5tKsekVmarAhcSTqbMbQ7Bj13CoCLPgTxh8eDhr5Knl+ddw0Ky2 vzxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=fZXSe+W5cVBmHn39qBn1fgW+vdfoWT/J0aoyP8tJEY0=; b=sacBNlxwTUMoFUtbh2gfR0TUOIjb+5AedLYoL1sLROTPrS9NOxNEQVwBGTrp/sk3aJ ssOsEZj/z7nr8lUhhSB7RfCml2Dn8XbDZu9CCiWaKBbB1+GiMivMbwWp1jVeplu5aMyK 9l1pDAlSFczWtZ14+45Zqqjydo0wxkExHlOBo0g0ehSRhOIR9Sqq9qYdjw8hrSn4nr+H VrxNF8TFl5I8xJRwEloS0CGsFEG5EsFfTDcUFClQGbGnrUHxgeqhDpJOgpIu+ReKSrfy niaIXc30UN6vFsBHQvG85gqa6zPE8OwbQADkz4VUWrLxO6MXGpiGb6XIeeNjHQnTPaop BpIA== X-Gm-Message-State: AFqh2kpUukxXF6YMIEGMvAep1TKZ98V0XjB2T6AID6t9B251xkNFoKEA /sS1vcVjPWUCSnKQYWq1hj2CJg== X-Received: by 2002:a17:907:1042:b0:7c1:5863:f8c4 with SMTP id oy2-20020a170907104200b007c15863f8c4mr33072684ejb.21.1674676276901; Wed, 25 Jan 2023 11:51:16 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:16 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 14/18] can: m_can: Use the workqueue as queue Date: Wed, 25 Jan 2023 20:50:55 +0100 Message-Id: <20230125195059.630377-15-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025476864338512?= X-GMAIL-MSGID: =?utf-8?q?1756025476864338512?= 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 --- 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 83ffb4c0eb4c..03e6466f9b32 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) { @@ -1820,10 +1818,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, @@ -1834,30 +1858,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) @@ -1885,15 +1889,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, @@ -2179,6 +2185,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 4437085f63b8..774672fe7d2e 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 Jan 25 19:50:56 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: 48286 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456541wrn; Wed, 25 Jan 2023 11:53:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXvUh+LzxhZorBfYZfbG8tlYFRO74f7jGED6U5y/XCs+nc4mLwm9BkXDMgofVGQqJEYOJhh1 X-Received: by 2002:a17:90b:388e:b0:22b:e768:5b51 with SMTP id mu14-20020a17090b388e00b0022be7685b51mr8929736pjb.35.1674676389146; Wed, 25 Jan 2023 11:53:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676389; cv=none; d=google.com; s=arc-20160816; b=UOr16CpUuuATS+YmavfrctQB1EuCaXbqcXC7iXdgZ5xK7eqiCnVZVgP+FqYwC3DJNg 8fQ3H1dxzlb6e4ajEM76yRdNjKVK+/0wMwQEWkLL8GvIIWRCNPF/CUYsZkrSX/yuFRAA BGJelpPu8zPuJuHnf7GRBYPkh7Uz/ZlceBJSmM5mZfiRY7PNFjuX/yyfgZw/nyC7MUXG lE/j9rLvQzm0iKHgQJDW7/T1dC1djpk0uJRJj9vT7cXv441khJoQEQN+o5eNjMYfdzCS ffqb1N6v6B+ae3yGIm3IpeNyUdNVW6eiyBzyLD5v1dQBgIWm8Kskg0JBpIJQVQn0JOM3 S7hg== 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=ted8XAaZ1TnoxK7fH6iDTkjZZNEKPE9wfSG8VYeUjqk=; b=PLn38UmzzP3MesLmyeNF4UXwuJrNsQmRIL+UkshECSw+4fOhbR1LMHwqda2LHPJx59 FkTWcn13ucQ+aXAAEytADYOOcQpK3+4aJXP5Zy/KJJ0yAMzivSVFwrFcxLpP/5OgmSBQ vBIOFwBeqB+rRK6KSp+j/KNkgJOsoMrNZl+9jRWEJtdPfBrBEGohhSOAI4+X3ZeQCuhz 8tFBspCQcUfy0Smr9n23lFefjPWbELetAWxjOnvD9PiPVriNjGwox3VmMLMDSojzEJ8i wMtKYWgXPSviwTitM1f0oRiDWdXlOV2jsaWqEB8ay478OTywKBxdG92+PS7SguYbZwBZ LJoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=qe2mIr2n; 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 j10-20020a17090ae60a00b00219648ff3a5si2679126pjy.171.2023.01.25.11.52.57; Wed, 25 Jan 2023 11:53:09 -0800 (PST) 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=qe2mIr2n; 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 S235858AbjAYTw1 (ORCPT + 99 others); Wed, 25 Jan 2023 14:52:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235913AbjAYTwO (ORCPT ); Wed, 25 Jan 2023 14:52:14 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7608B59275 for ; Wed, 25 Jan 2023 11:51:18 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id ud5so50648417ejc.4 for ; Wed, 25 Jan 2023 11:51:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=ted8XAaZ1TnoxK7fH6iDTkjZZNEKPE9wfSG8VYeUjqk=; b=qe2mIr2nd4mX783B0kBepfkS72z7m+aFy+ZkMHSBbNPMAT0CEtJDL82svj1DWS8cHx VxZamFivlH1O3qCdQtp/LPPJw+0opMQEoSMyVW8ZeJOAZYKrx4nCBCw/q+yXNwdHlikY AZ6u2iK9G/PSgfT6vb4S7Pdgz27xjBP4SoMnarT+qOkG8dzsUckBubXlpt5t/YczZVNv pLgl26D2b5oKEncBqUXlNDLIe+u5Q3mGsoi2Fk+Mo0q2inFZjatCS1XIcGFiu/fhxUQq Z5OMmkbxQo7q/jZVVwOui4CEUf9ZLyibCbKQjvxbUc+e2n8mO8/wE5iYHnGDnIYE0s3+ hZ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ted8XAaZ1TnoxK7fH6iDTkjZZNEKPE9wfSG8VYeUjqk=; b=0aiDFAKFYbTwbCSKp74FtQXC4zjEb5n2n07G3fySkgbBWP4XnlAo6CslgH+N7MFm6u BQN3JmdE7/zuwdWzB1BtHoeqXN1kBdk1CYM1/kjA+CDuACMiZAkp9RLF5BGZbZw5iThz bNiEgGA0O3LXBQ/JDDvxhFUimIOumVCJW+b1IkLyCNIAddf8pZPN/eiaY5LLpeoNJRA1 CeHfUEC/TTfnBYICk4KwqI5M4vEheQDQBW3xsQHrc0A+jj05rx+pijcG02r0lqiS2zX3 +Uykllj6L4fCIul9KfKAUVRW6FhgOvvuQhtFzqEs7yDt8rgIpAZkiH2ZVYsvvwhiw66C mmHw== X-Gm-Message-State: AFqh2koX3ujg9kFdZpp/PFP+ElH/6p/xDVUgUfGBlgNmfkFg6+r5xANB 1KLH0Khy6QVmdKkvZUsu4tBZ5w== X-Received: by 2002:a17:907:3f20:b0:7c0:f7b0:9aed with SMTP id hq32-20020a1709073f2000b007c0f7b09aedmr45200898ejc.55.1674676277826; Wed, 25 Jan 2023 11:51:17 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:17 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 15/18] can: m_can: Introduce a tx_fifo_in_flight counter Date: Wed, 25 Jan 2023 20:50:56 +0100 Message-Id: <20230125195059.630377-16-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025469623445368?= X-GMAIL-MSGID: =?utf-8?q?1756025469623445368?= 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 --- drivers/net/can/m_can/m_can.c | 36 ++++++++++++++++++++++++++++++++++- drivers/net/can/m_can/m_can.h | 4 ++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 03e6466f9b32..f46d411bc796 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -453,6 +453,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(&cdev->tx_handling_spinlock); + cdev->tx_fifo_in_flight = 0; + spin_unlock(&cdev->tx_handling_spinlock); } /* For peripherals, pass skb to rx-offload, which will push skb from @@ -1023,6 +1027,20 @@ 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) +{ + spin_lock(&cdev->tx_handling_spinlock); + cdev->tx_fifo_in_flight -= transmitted; + spin_unlock(&cdev->tx_handling_spinlock); +} + +static void m_can_start_tx(struct m_can_classdev *cdev) +{ + spin_lock(&cdev->tx_handling_spinlock); + ++cdev->tx_fifo_in_flight; + spin_unlock(&cdev->tx_handling_spinlock); +} + static int m_can_echo_tx_event(struct net_device *dev) { u32 txe_count = 0; @@ -1032,6 +1050,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 +1080,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 +1183,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)) { @@ -1845,11 +1868,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) { @@ -1861,7 +1895,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 774672fe7d2e..bfef2c89e239 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 Jan 25 19:50:57 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: 48290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp458518wrn; Wed, 25 Jan 2023 11:58:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXuSQhJLwkGv3KsUC/ZjpZx6kvXRAcZuN8MvDy5Y+TLQ6vO5xfZfZ8LxedkNo7PJt2m43Np2 X-Received: by 2002:aa7:8650:0:b0:574:cc3d:a24e with SMTP id a16-20020aa78650000000b00574cc3da24emr31455091pfo.5.1674676703929; Wed, 25 Jan 2023 11:58:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676703; cv=none; d=google.com; s=arc-20160816; b=YcT2+jKftVaRehVhx8ypNcBeAXEjpjDxUreZW3q6oeYWbKOKJqzUxAcTOmKsi+A7c6 tfEtcdoSYg+XRrrdyMZV7ZH7t/+PWG2xNdtPwHpVr4qjnwjiasaDBIw+mxZ6Z8/9qYBa dAJzm/K+9cYxR/H4IrloIEtPTykhfQQvDci0XDFLqnoOpSxk77Rp/UFrCMKDAdPX6qxZ WzVHMnWCnPCGkGx5ewmFp2E3vhpwBsNDS7V66X8IAsQLxiLBOja+d0yq596ertpb9Kq/ zWog1sZZ73uJ4ofxixXKXGcaFaMGVnFVHFi1GFlvBkYEMY7jwbhCxMiHbblQTYQ8J9hO iusw== 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=/2Jin9e2wGMdlJd7lrmLtm7VXCmjAGgCkfI7OuGO0k8=; b=aq+hnURwM5l2qpswSpIUZRIy65KwXDZk+6hKK3lXRP6YrtN0eUh6T8WJ0dsro8Vrww Lq+/gfATXK2WGBgOLL4f6l3eD19f4LyXDQPLuVp+ygg5ITAkEVHGtE8vwp08syfBPI29 vwFnWV6C5kEpRgqXoAQAlewOotAOrOM4r3V9BQDj8rfXCKDQtshxlDH/bU01Av/c/COu PFkMhIZ1qFAHQWUKs1/sucxiMpF/Yo3lvIILMzwpYLmPo8tipR6qh9AgE5jI10+lC3cU sTIofTug0wQ9gFZMb6BHagrcS8qDVMfViG1wI24qwnHDI5x6A3ODMA7gIgvIL/FL49b/ wZwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=Kgfdprj+; 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 y5-20020aa793c5000000b0058d8d935148si6499925pff.253.2023.01.25.11.58.09; Wed, 25 Jan 2023 11:58:23 -0800 (PST) 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=Kgfdprj+; 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 S236123AbjAYTxD (ORCPT + 99 others); Wed, 25 Jan 2023 14:53:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236014AbjAYTwY (ORCPT ); Wed, 25 Jan 2023 14:52:24 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C865E5C0CB for ; Wed, 25 Jan 2023 11:51:21 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id mg12so50608046ejc.5 for ; Wed, 25 Jan 2023 11:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=/2Jin9e2wGMdlJd7lrmLtm7VXCmjAGgCkfI7OuGO0k8=; b=Kgfdprj+f/gxPYmLAXckB3jmwQRo6mqGmAUulpumtp3Pe2PU9Lsc+iIlUWKFPehJnO B8hf+amxB5jUm6sN6Hlvpajunea8k5dxSQEIpDsXW0dSrxeKoTIFv05VyIZUXKqz2OXK Ie55v+mPXla4xFuHupg9rJHCpzL0S/JAC1wZu4qvG/TKPuJ2YVm+Fd25YaedR1DOTpRI 9KCfAHJUvTA6KDXs+xKtXgT25j+OBq0tWKEPZGXiHjE4K5lZgGsSzn3P1zqthZrN3gvg E7959MrU9KQTX+hAiGAU+yEtc4C1GhnVpU0BpUqC/QwFbXjYJK7wXwGfrXFkOJjvR0xB RItQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/2Jin9e2wGMdlJd7lrmLtm7VXCmjAGgCkfI7OuGO0k8=; b=cGDL3s/2N7zO3lJKIdxj4obmTrF+ilsILNOuFclnzi0tTOk4AlnngpZ0yWB8ntJoL9 9quZcl/YWfmBQ3vNI11dtJ7ScyvtKPeWaYRJDCtl1mpa9FFKnCF24akG0BPI65dwPKQ1 mIOlp6gtOVThPOgn6EOsra0KVP/j/wqeg+a1bWcr9bDKIRRJQML1rIcGjro2fhldJCOH 5KcUpFyOqWZz8LUvdoFQG7uT0ekALKpowoI80zVg7S/crGmYN8gE1q3u5jnp8hiMB0JU fvPs3CpHcGxS751VXMQNcO9EW1SAnx2LCzuPleGXC9rru3U/vjBXOPh7le9kvRo3LXPb Q36A== X-Gm-Message-State: AFqh2koUWBPU7NplyzQjrBmd9hdh8npWM/eiVvA85tb52kKAmpi/U8Ii Uh5TT+RAigo6sttILLvz6GS1Hg== X-Received: by 2002:a17:906:80d:b0:870:d15a:c2e0 with SMTP id e13-20020a170906080d00b00870d15ac2e0mr35237171ejd.51.1674676278696; Wed, 25 Jan 2023 11:51:18 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:18 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 16/18] can: m_can: Use tx_fifo_in_flight for netif_queue control Date: Wed, 25 Jan 2023 20:50:57 +0100 Message-Id: <20230125195059.630377-17-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025799712737853?= X-GMAIL-MSGID: =?utf-8?q?1756025799712737853?= 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 | 72 +++++++++++++---------------------- 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index f46d411bc796..b24ca7a1ecfc 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); @@ -1030,15 +1020,30 @@ static void m_can_tx_update_stats(struct m_can_classdev *cdev, static void m_can_finish_tx(struct m_can_classdev *cdev, int transmitted) { spin_lock(&cdev->tx_handling_spinlock); + 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(&cdev->tx_handling_spinlock); } -static void m_can_start_tx(struct m_can_classdev *cdev) +static netdev_tx_t m_can_start_tx(struct m_can_classdev *cdev) { + int tx_fifo_in_flight; + spin_lock(&cdev->tx_handling_spinlock); - ++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(&cdev->tx_handling_spinlock); + return NETDEV_TX_BUSY; + } + } + cdev->tx_fifo_in_flight = tx_fifo_in_flight; spin_unlock(&cdev->tx_handling_spinlock); + + return NETDEV_TX_OK; } static int m_can_echo_tx_event(struct net_device *dev) @@ -1182,7 +1187,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 { @@ -1190,10 +1194,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); } } @@ -1714,7 +1714,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; @@ -1770,24 +1769,6 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev, char buf[TXB_ELEMENT_SIZE]; /* 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; @@ -1824,11 +1805,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; @@ -1862,14 +1838,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); @@ -1879,7 +1857,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 Jan 25 19:50:58 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: 48291 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp460821wrn; Wed, 25 Jan 2023 12:03:12 -0800 (PST) X-Google-Smtp-Source: AK7set8CeUCLirilTkNYEtv6kOvY2F1lmizoHl1Ud7mXly2TvxaMZXlpACBzNpdAieEBZUY41AY8 X-Received: by 2002:a17:90b:4c8a:b0:22c:1735:4298 with SMTP id my10-20020a17090b4c8a00b0022c17354298mr973229pjb.14.1674676992577; Wed, 25 Jan 2023 12:03:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676992; cv=none; d=google.com; s=arc-20160816; b=W6hEWzxLtl+418kO1sURKlyaXqNGUDd5vRM20H7+kaeS2blGHLo50BWoaRom0fEfFo +rJDJxoUsSqMxmYGQB9QZmvjGm+k9hUuSJq9XavaKTaY4eCB6DWvetyp2k9fbMxDYKNw 8bFJTZVhGOLG3leMMzhGJiVbUxb/BZ8LXWy2BxHJObI2msClFNbBWDYKpWxfnHIql/7u ZD6bjrmYX1Z6oI72ssl5V0thoyvN1+BBdixoFwGNSKgbMQukA1PyBYuAdK1I5AOIeYDU 6KERamQCvxB8IjPO+l5XoBGzxh6lLb9f7erMaTK4CopVb3A57ufFDUHRI0b/uYTXNz28 vqHg== 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=ffISOqPrjVineBfCgtfl5Y+ak8BEEFsQWDBR3c2ME1A=; b=Uj6Lqgu4U6sFPgYHjkv+3kkVm/b1feXIWVXea/YlDG3Nk8uUgY6qGGoE8gVFs+lVQQ zQpEOugUlLBkQY/a3VYM5ohGpirfQHOg2Nw2UQT/QcKGpBJgV3QxYSe+3NIK4y1TKjP2 q6UrjYdBBESGB44vMlChMbAQ52Xc8dwketTyyRss5PNj0Bo6fvqkcmZA2pXzjcxpSzWX 1YF/+fb8Wgmqw2r6BTzIoCe7SNNdTExBKCCKYsspj98S2pk6aEXVvqZ8eZgtGW2bVRUX Tx9c5qWkGjU6RJT8EvoKsDeKHh+WGcLQiMUn4Cst8+HB7rSam7BupIYDTgstDQONuqE8 eV0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=0VuzDqRw; 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 p1-20020a63ab01000000b004da09fcce33si2616828pgf.583.2023.01.25.12.02.55; Wed, 25 Jan 2023 12:03:12 -0800 (PST) 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=0VuzDqRw; 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 S236090AbjAYTxA (ORCPT + 99 others); Wed, 25 Jan 2023 14:53:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236160AbjAYTwY (ORCPT ); Wed, 25 Jan 2023 14:52:24 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD45F5977E for ; Wed, 25 Jan 2023 11:51:22 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id kt14so50661631ejc.3 for ; Wed, 25 Jan 2023 11:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=ffISOqPrjVineBfCgtfl5Y+ak8BEEFsQWDBR3c2ME1A=; b=0VuzDqRw805Rh+kKcAf2Kr4irsZmGV3zH28nntM2EYVNES0HnLhs9pwkq3l1D9agU9 QoeI1a6uzVFwLUk6GTzaweHSluK4GvqIHb+lpuxKzL4JizJUSeOx6z4J8CP4JSJaBV48 MH7P9bTc5yJV4xFSjl4U6nG5h1GOyioXerSXqtMguE5XIx/IcEOnNYVw/RSNtBcBtybq iiEcmAwuPSVrU2z+nZXkxxS5ZDLKzq8xZmAqpY6WmupxemW9ySjYHFrpr7yWrFspMyjo 9C+XHxyUXUtLrzMfn3v8fbrdHH+AipIVwsDjJIk8+QfzKKAuUQBh/nHYWu3Ss1xrP+PZ 4FvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ffISOqPrjVineBfCgtfl5Y+ak8BEEFsQWDBR3c2ME1A=; b=t/bjID5xSjYG160JWbYHkUomv5a76PcvgREVdYVA8wO/REA0lin/HUiPsQawq8Sp0r HnhmfEO0fJQG68pp5zy96IJJlsYA3P5kJttDK2nclYfITzbzisTfnNCD3dVL9m5M86vD Vs9Aru8tnVlDi9AhX+IoiH4d415WAy2JqUk1QaShhfdR6rSyd0llkN2hUVsNPUv259L2 5heSmAKvLWC8meSAdg1kqWuHHML/+niZwrysengmbAi0HP7sPYkKhKrc3i5E5+cIezWf PA3QXkts3jVFOdssv4pBpFx/GFFpTqr4Pf72Z0L5ep3Mcs5BmBmRnT1HM9V0Ul7xxhyg iHXg== X-Gm-Message-State: AFqh2kqJvpt1BD74sJeuT6GeZ6rlf5ex0o5qD50yH8GmPVxCgtkYNSB0 1Eq4X3xir2xz/KGbY0eN5vvAGg== X-Received: by 2002:a17:906:2c55:b0:86b:d25:450f with SMTP id f21-20020a1709062c5500b0086b0d25450fmr35270088ejh.25.1674676279544; Wed, 25 Jan 2023 11:51:19 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:19 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 17/18] can: m_can: Implement BQL Date: Wed, 25 Jan 2023 20:50:58 +0100 Message-Id: <20230125195059.630377-18-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756026102281340177?= X-GMAIL-MSGID: =?utf-8?q?1756026102281340177?= Implement byte queue limiting in preparation for the use of xmit_more(). Signed-off-by: Markus Schneider-Pargmann --- 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 b24ca7a1ecfc..c6a09369d1aa 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -444,6 +444,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(&cdev->tx_handling_spinlock); cdev->tx_fifo_in_flight = 0; spin_unlock(&cdev->tx_handling_spinlock); @@ -998,27 +1000,32 @@ 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) { + netdev_completed_queue(cdev->net, transmitted, transmitted_frame_len); + spin_lock(&cdev->tx_handling_spinlock); if (cdev->tx_fifo_in_flight >= cdev->tx_fifo_size && transmitted > 0) netif_wake_queue(cdev->net); @@ -1056,6 +1063,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); @@ -1084,7 +1092,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; } @@ -1092,7 +1102,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; } @@ -1183,11 +1193,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)) { @@ -1716,6 +1727,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 */ @@ -1761,7 +1773,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 */ @@ -1799,7 +1811,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)); @@ -1870,14 +1882,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 Jan 25 19:50:59 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: 48288 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456757wrn; Wed, 25 Jan 2023 11:53:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXtAJnpH4bHCEmP/npCTgJsDnGhgXRUjgj8k3DWzumOvbe+DXv0P+b/QpAS8+dkNQMb1+r3I X-Received: by 2002:a17:902:e54e:b0:195:eea0:5712 with SMTP id n14-20020a170902e54e00b00195eea05712mr23997821plf.38.1674676417134; Wed, 25 Jan 2023 11:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676417; cv=none; d=google.com; s=arc-20160816; b=ZeFMDvD+C7q/z5Yi7Jsq2Q+zhakb6K79syyp2mvI/zJo9hX7tGBPxEreD357uxpsnF 4elyU1ZffTmw1IHWHixrmgBWfPCBajl1TI+b3TrPp5RPeQj2jq6yA3+AEW51hYojQPB/ wr5O1Q5Ach2+5zu56yCFkiDuyLaTCrMh7cD3SCy5vzv1n3p25+Edcwico4sUJxVdOzzc o39fbhc8dseoEB67IndTz78JOhKHYYbwSQLXfQkfUaSlKh3N8t6sqv+N9B/W6iJqZP6a 2qH+p+tiM28Ej8veTIXmfIWZ+pLx1747g9ZV9iw9EMepLDLlYM1s14tuGzLMmlJgkgUP A9aw== 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=PGQtNMCtF/zFqyjg+RVNx/g2xphXepovgWysJqLnw9w=; b=yoGitHYOmxcZbuR1XEr2CllEsqM/e/Laoes00zuWPTEc6C7TX0q9ss321KGEUZCORR BMT7GCvCPRRtcl/XjKewYSjSMEflbNHqrb1Muv7qNsXzI/B762EAen9AzJ5+MTLl6DL9 HxNL0vcQ9tFom0XXmKpjZVx+cALSS4iuNpXfj9O3EK1pzhJkxK0BQncl1hOu0ZJHMUaK 7nJkYryoDMqGBfmnx9scvhgOJOCFsOHUXJibmn3ZC1zp52Sdzd/AEx7Whce35Edflmps kHjM1zUbDS+Xwx0HauYyuekw68PU4GDXU8sP997MECm1kTGwwOZK0Dd1odtlu6RLaECX 3eFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=eJR9aQkX; 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 r11-20020a170902c60b00b00196091d83c1si6018254plr.267.2023.01.25.11.53.25; Wed, 25 Jan 2023 11:53:37 -0800 (PST) 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=eJR9aQkX; 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 S236166AbjAYTw5 (ORCPT + 99 others); Wed, 25 Jan 2023 14:52:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235889AbjAYTwX (ORCPT ); Wed, 25 Jan 2023 14:52:23 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0CF15924A for ; Wed, 25 Jan 2023 11:51:20 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id hw16so50534063ejc.10 for ; Wed, 25 Jan 2023 11:51:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; 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=PGQtNMCtF/zFqyjg+RVNx/g2xphXepovgWysJqLnw9w=; b=eJR9aQkXDReiK2529mb60Vo419A5Bu6Z3u7WpIl4js2WhPZGIQFSy/H4+p4NVIXaJc r7Wbb01tc97SVywSGhQ06K8PuXb1eFANcGB8N/1W5TTdeS7VMXfrSvxFtptvIY24zvpK UJ7aqQyuF3PM4yk6FlpHbu+TZSzo8e4rfvZ4fMHZQ8z0Vk9JpnOm9/Kj+XbuQ0Q0I80K HtDArDVy6VCc8K7Fbbt5DA+7BHe+/eyH7VEkdLOELJcleXkz5SwhrXM9MpW1gONi1uH8 el4p6hcH8QcBiHyEjnjDmJakvDDlTxv8p3l+e/wf/mZ6C/p9JacVIvhmZSJfdZNRvVfj /zcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=PGQtNMCtF/zFqyjg+RVNx/g2xphXepovgWysJqLnw9w=; b=rRbGOo6NAabjRLllUJqgLiY+wlj4V7avzD/k6bGE8rogzaSF0zRx5K8wt3/oflfVJy fzLXZTM6WOr35NT7XL1reghkintNzr7pR6og2KRcxfv3N0ASjEa7mrJrpqu67rCr7YdQ RXwa12/z9nsJqITh+XfMGCiQccPxwxdnDdDpGaInNa3eOnpEwz/1Wmpti2bgGVqtEylm KHzYmjeL/q9t9xmE5eNAVmbDpPI6Ovdp5FMpAN2t1L/eMPl8KC8N/rXVygh8DlhWsG0/ FH9Y8IM2l05AfkSG0bsnh8lPwm/qHpEybLMxSoIWOCtVtCPKQTGZAzvBews5T8N6c/Qe +ygg== X-Gm-Message-State: AFqh2kqcplQZYiJIQmeBiC0wM1dkdqhghrtZ5MZTQTLU/JD1OAOHlyV6 tbQNc7oiz0FGrBC9UXtu4SEIMg== X-Received: by 2002:a17:906:2582:b0:877:573d:e91c with SMTP id m2-20020a170906258200b00877573de91cmr29810674ejb.63.1674676280502; Wed, 25 Jan 2023 11:51:20 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a247:815f:ef74:e427:628a:752c]) by smtp.gmail.com with ESMTPSA id s15-20020a170906454f00b00872c0bccab2sm2778830ejq.35.2023.01.25.11.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:51:20 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v2 18/18] can: m_can: Implement transmit submission coalescing Date: Wed, 25 Jan 2023 20:50:59 +0100 Message-Id: <20230125195059.630377-19-msp@baylibre.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230125195059.630377-1-msp@baylibre.com> References: <20230125195059.630377-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?1756025498760380458?= X-GMAIL-MSGID: =?utf-8?q?1756025498760380458?= m_can supports submitting mulitple 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 c6a09369d1aa..99bfcfec3775 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1504,6 +1504,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); @@ -1813,8 +1816,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); } @@ -1827,6 +1835,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); @@ -1835,11 +1854,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; @@ -1851,6 +1874,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); @@ -1861,7 +1885,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; } @@ -1993,6 +2025,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; @@ -2037,6 +2070,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", @@ -2047,6 +2092,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; @@ -2064,6 +2110,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 bfef2c89e239..e209de81b5a4 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]; };