From patchwork Wed Dec 21 15:25:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586169wrn; Wed, 21 Dec 2022 07:27:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXs6tYCQLRIrTP7efpa6gT+VHokimCYDaKLO5GEwaR33TwpJXhRLKkb/x//BwkX7pyFThS7d X-Received: by 2002:a17:903:2447:b0:189:8141:e827 with SMTP id l7-20020a170903244700b001898141e827mr2675810pls.56.1671636427860; Wed, 21 Dec 2022 07:27:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636427; cv=none; d=google.com; s=arc-20160816; b=kSlq0gHXWf7dQ0nJuqoSu0kDvZDHk+MndYHKp8Yx3s3pVgE6ZxuC0+bU0f3uY0aOWe +o4seiDGcEHvnbY2tHwpaiAcryJ0IJ6HWfqa308cCW27e3H5XfHm9TaeKzuwqNBmBUef dsNVG5Qz8yenJYhJpMMx40kq9v7FT9xVCOfwbGYlvhCR9Uzy1wpDarCELBub5picktDp +ltT/RPwgUWtcZ7kZKdbqpahC8dKDy4wLpuZODQADx4hrRIYUcggngcYRmIRlypL++yi 9GZi7umQh2vCCIzW/IllwqO/llc/yAH9baMeVIT6J2KXg8tOhV1ee+uYLV7ASdaWESng pH8w== 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=HU1fM1Lkfa3GCTAXKr+w8jT2gXMcP3RN7DZ2MvUOkc8=; b=ZZ2TAtp+HfJx3DEApSIU31l+oKYulPGcGr4Ocmc1vnfsJcGeO/xIdAAOj7XcTtQQzb 7IWMSioxYYDXblJO1cGsib+aC9FAsh3dln/Ekg2reFZUjWi1qpnNdRT0b96lwnbpCzoC CPFXFgZr6txGysuaNJ8/30izm8/v3Z0YVQ2cgNr0kkhGpyp+QATkPp9b14Bj02d820fm 1lGedQ4dHDBfbs8vHEL0Heo0KiM8K3saN9fFwbaL9o5DJuLLukEnTcRGs6lS9LBgj86N UVWe5crt5z9GKmLcHAs5PkXPbxPDdtnrglT9k2JSFGnPpj2kuKgimvFVFdNlWirJkTfn aA3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=WtYsqbIL; 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 m21-20020a170902e41500b001897bfe1ec1si15222603ple.345.2022.12.21.07.26.54; Wed, 21 Dec 2022 07:27: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=WtYsqbIL; 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 S234605AbiLUPZ5 (ORCPT + 99 others); Wed, 21 Dec 2022 10:25:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234598AbiLUPZr (ORCPT ); Wed, 21 Dec 2022 10:25:47 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DB85F2C for ; Wed, 21 Dec 2022 07:25:43 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id s5so22401891edc.12 for ; Wed, 21 Dec 2022 07:25:43 -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=HU1fM1Lkfa3GCTAXKr+w8jT2gXMcP3RN7DZ2MvUOkc8=; b=WtYsqbILYftz9L6zgOypJZRybELx1w/ZwOle04X7RjSeaOzSX9dfIq0MlOI00pcnjW w8VrrKfUe19RUPuUB8GtaYjdXRRd9Mf/ydmkXRgqWu8FV60YW1/kkpWfWF0owTOsTuTf DSJsdsGKZpyr/iewDGgSYILZhOTpYuLEKNX78jRIjQvuOICZPs5kWwBMNfXLn2reAf4U q+ch1/wBGACrelb1yYqQCO9xtPXtQMu7SdhtW7aix7YndS46sjLdo2+fhffTFI0tOX5e cQEh62Ts1JGOA7BMNPmq2EYDFwRjgksrsjTaMPFoRWGrmYcnQtfp7JAnDm3oeK2PbFp0 34Sw== 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=HU1fM1Lkfa3GCTAXKr+w8jT2gXMcP3RN7DZ2MvUOkc8=; b=JbixkD8G4gFAqZCfXaQ3Yaid6LMq3ZBGRpKaeoRmcLrGKmLcXii6xj+qZmvZAoy0hx ekp4i8UE1JCJkLmfMpJCRt2v32HfqWVjbZbdk8XzGYUnIr6Pjim/WLK3EdwIS1msq7YM xkYM3oubSustE36PoLWDvgeM7Mps0N/eKBiGqIDIveZVeDbiRUXZOO/lOehYVodvxxSO W9K7ORH1EDvTqJzBZAZvRa9hy2jC0k9P9p9pq7dGY0N398kTc6txwJphrunPXclamxcz JolxW2QXKpwicccS0ktnO49US4Gp5PnhWQo6ASuc1VmqTcXp8Ipi5k8zEOzOJ7wVqCtF dRQw== X-Gm-Message-State: AFqh2koYvgUUJZ4Ma4DhuJT/yS5tUOEEz8xxdIyOgMf/T9RprCshm6JX KqFfUWrz4eY1flJgeBiR+iYQZg== X-Received: by 2002:a05:6402:38d:b0:46f:b2df:4e0b with SMTP id o13-20020a056402038d00b0046fb2df4e0bmr1836537edv.14.1671636341814; Wed, 21 Dec 2022 07:25:41 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:41 -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 01/18] can: tcan4x5x: Remove reserved register 0x814 from writable table Date: Wed, 21 Dec 2022 16:25:20 +0100 Message-Id: <20221221152537.751564-2-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837839236753791?= X-GMAIL-MSGID: =?utf-8?q?1752837839236753791?= 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 Dec 21 15:25:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35398 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3585946wrn; Wed, 21 Dec 2022 07:26:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXsp4fVD4+Hn9mtJoJ1NmpR9b6rvCxF1GlAbLnnZzFmRkaE+PXwnd+QvZsRuXOujZtwPhnFV X-Received: by 2002:a17:90b:46d7:b0:219:fe29:ad9d with SMTP id jx23-20020a17090b46d700b00219fe29ad9dmr2653741pjb.25.1671636402317; Wed, 21 Dec 2022 07:26:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636402; cv=none; d=google.com; s=arc-20160816; b=WMLIeet/RO4NX7xnCucAGmri9qmoNAutkgSW3jvmGTaJ4K2w2esiymZNgrWVnjgcet ArrWKRPU2N9v37fxOBQQVPQDYwztd9gxSfGI4SVdeJSxEF698SozzplJXjKn/fRZ0+xU JPVVptN1WC+njODZlCWJgR/5o2IXxYPTNBo6A3o7U9wA+T6JfgPGxqEFx6RKWHWMQbWv Af0Zh944x+mBSFAe3DGSbJrDsCKBQ6jtg0Kxz03NC2DOSqnst/9CIy0JMCRyUM3p7BiI ZDTFVFlyB7IuCLQFMRUDGvlyp4aq86AR0kWKb/Q5tdQ0fbwf8oaFEhkQUo4jKNuoAaFi Y/Fw== 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=mDXoKkBf3QKLFoNBUr2onp8tCGWeovhpj/ofZ+JjjAU=; b=zR6xK9qcsKuXzqgk1O7v4EeQWRRDVFmmeiWzBPguZHDb9pjQIp7x24+km8WpVFmHGD HHwg0x0apH1gWllya1bsonNcAAryESAYkmO+vOLMHYMFpEmDzTTX+NN9Il/5FSqTLi4O OGv8309irVD4xp9ZXqZeK3/udqlslQnBIb68RZgHkrt+Jc81f3vWM77yOK72w/TEe44p Zw3dEHSWnL7wLJOO7DNmeiSDWyvinM8WdKNo9wdEHgoGfWuhZKlQ/JRYhAr2H17ioOY6 JgxCHwwmRvyYpIpLx9AtJY7M2Bu5F+2fKNwpKgbMXOW1jpYL1HDEEi986xl9Aid+owHt jxYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=TMhjNigS; 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 k69-20020a638448000000b00490a1c37b20si3995884pgd.615.2022.12.21.07.26.29; Wed, 21 Dec 2022 07:26:42 -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=TMhjNigS; 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 S234602AbiLUPZx (ORCPT + 99 others); Wed, 21 Dec 2022 10:25:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234535AbiLUPZr (ORCPT ); Wed, 21 Dec 2022 10:25:47 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A34610BB for ; Wed, 21 Dec 2022 07:25:44 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id a1so7451607edf.5 for ; Wed, 21 Dec 2022 07:25:44 -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=mDXoKkBf3QKLFoNBUr2onp8tCGWeovhpj/ofZ+JjjAU=; b=TMhjNigS1DyIwH8CyjsHocZyaHTt7KyK/ZCjumwTN9EBxfeVWy11UJZ/hucZ2QgmKL i9+S6Mr5k3JlxoN74cBxQBq5gFNneK9tZoVKVuhnXkRB+1GzIbXAOID2fxatGI5h++TP Zg9ZUwqOFDAJMcdoLKzmPTzBXPps2BJltJYupb2iQNZHydtKxPrU6WqFRuRBLXcQKyyd RSGOLfNeeYDV6fqcRTz8VyNhfGn9nhcgt20R8gwBN4q/t2Qht1mRCwJLS7+fMZZ79ntP IbRv940LZ2xjde+/NVeGOgUh4xPCi4R9M9R3FJQF2QijNknp5xw1uMDXBgb9s5+22ovo TWNg== 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=mDXoKkBf3QKLFoNBUr2onp8tCGWeovhpj/ofZ+JjjAU=; b=Wta7mCLfXbZUJ5cVlE04zzv1AQ2zMSUJnA4xY1dPX7NvwqVQPSEPuWmdR/ns0Hs3RZ 8Qv1WpC/jXQhhxrkk+qb2xnG1jKbpERDuky+/P+VcasAYprGW7Q7A/C9/gXLDBmNkhB3 WAVTjjjU0d853xRGmYoz2NQzLjSwBNTCGEKcwLOMQz04LgCMpyvNuLKRAq04pQF2vuDO JbA0jcU8fs2qkYRpkXOHft0sQcqAB4Qy9qSHeQL0+2UCJDJQ0q2GJA/aQb9fNA4GIQlQ R9Jdy35E+Nt5MBwOf2TqkkhhDL0f7SxaKRTCLOnDJtKsDjteKU7bq/5Gij/yeGMqkvMi 6Qzg== X-Gm-Message-State: AFqh2krKUKZDgaEYH8E01PPY2OEov4mLwdFsUFmB5YmAetE0OG7p9wbI HOYlsl9/ORKFGWxQuHdUlyGnCg== X-Received: by 2002:a50:fd10:0:b0:46c:97c2:8d75 with SMTP id i16-20020a50fd10000000b0046c97c28d75mr1720946eds.21.1671636342810; Wed, 21 Dec 2022 07:25:42 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:42 -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 02/18] can: tcan4x5x: Check size of mram configuration Date: Wed, 21 Dec 2022 16:25:21 +0100 Message-Id: <20221221152537.751564-3-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837812134292453?= X-GMAIL-MSGID: =?utf-8?q?1752837812134292453?= 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 56f07f2023dd..f3ee21ce6109 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1860,6 +1860,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 4c0267f9f297..d2c584232c1a 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 efa2381bf85b..4f5a3ade6de2 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 @@ -312,6 +313,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 Dec 21 15:25:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35400 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586032wrn; Wed, 21 Dec 2022 07:26:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXuEdGloTRm8pbq40yyMVOnvDsREy96qcPz3Zm8ddNhluf6pAzHsFRtkXuDusaQQY/0vboPY X-Received: by 2002:a17:90a:4e8a:b0:223:88c9:b17 with SMTP id o10-20020a17090a4e8a00b0022388c90b17mr2680112pjh.9.1671636411585; Wed, 21 Dec 2022 07:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636411; cv=none; d=google.com; s=arc-20160816; b=PUxq2MIGYwSE00U1dX3Trt9EpNxjrOHYZefIHnBbPwc1WCcr26759L+UnrxNWExXhn gKctrEV811pB/ozR8oymFcwWUiNf12df+fEO8aH2I5kL5YYaYyFoDTFo5zcTkAEO732M yBWHAPYub/5536ur69ayMac2ZzHziixC5t89x4L1dmhAygRUgfSQ5ZVTnojUpwZmp8Jv 6V45jvbuLZZhn3Bbe9qkaOKr1ZC7/O35PVuBP/ulMBhVeUJTJWQuEjjic4B1XCZhCiTl fbPehL1tqRbYlToOcA+3glKUaeALSAiqEgbNBUDp9BJiLC/5WLf9hJrKbntXU9h7v9Z9 XkSg== 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=o+yme8fXO1k6A7s/D5dm0smB9lGyLseYaKaraSpk4eI=; b=tvRwwMQcKuxoAu1W8BrkG2qpb4j/TlTWxI8XDo4M2XpvwUfqXshKEaOjuql/Ccx/pi 7Pgemm6F+sPnbsctMbLEi4+3n1/Tiqh/Pj5duj4KOXdSDJjrqPbSwvZozzqDo90Sn5yV LOg/QtrGdUrzk0YlBtSmQl4NdUhsdOjggIV1yfKoOoN1aelZA+3mhObCuLceWDjWu/Ex l61B7K/rCdeZQ8Gjp8bZ9EhpljrpYIuJCbHS4eL2lXud9rz8JJNBr7VLMYCcCmAvY46R AKTptxkaNIqm4bn3VPBMj0LyPGPgfQM9dEBjnh/ql6z7mQDGoqB1Zcm0jqFA8AwXAkvi fgyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=y3tpr8tN; 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 r134-20020a632b8c000000b0048e5531bc09si6247508pgr.277.2022.12.21.07.26.38; Wed, 21 Dec 2022 07:26:51 -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=y3tpr8tN; 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 S234694AbiLUP0D (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234614AbiLUPZs (ORCPT ); Wed, 21 Dec 2022 10:25:48 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4729A1120 for ; Wed, 21 Dec 2022 07:25:45 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id s5so22402022edc.12 for ; Wed, 21 Dec 2022 07:25:45 -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=o+yme8fXO1k6A7s/D5dm0smB9lGyLseYaKaraSpk4eI=; b=y3tpr8tNDFKTiSH+l3HSSVqSypavIYRgUCdD5vQ90b36Z2HjfdRi6sguvae0ccMetm D2yr7MTF/FIPYmUNC1j2X4CZ3l8m5GovPkDvxcAQGoodopd9dzFpQ02ICNMxftef394x ceX50juaGs3TyrlQpoXFEuT5ddcpTtiLeCqJ//5mi7r9Zz0fy3LIOVYhC6Q+7Sy6ZLjo hDtWmHOoHxNlomdNzYOUByJAzuL3m+Plas1pxeoENGJ6vYkG2lKIGXoY72lvzf0SUTID FQ4A1ZKDYRcmTtPAj3d54ytgqrhR3zHdGbjFyVBspU4e00j/AUMUyZdIsDH0v2sQJgW8 Eynw== 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=o+yme8fXO1k6A7s/D5dm0smB9lGyLseYaKaraSpk4eI=; b=wl6A18Oo/VddefFwBxgNJFbYJVT/DRL6FCubv9li0M/jkkQhUQbSS1m7eELl18MSPC b83mXByEFMgTZ9HUIGN6enWujJY7FyDS3mUwmS1BO5Jna0cn1UmGn2K4c2SgA+IFfpWM 7KGU3nJ6DZ2W4/GhZbUUy93Vkzt+BW3GVII59aVhdZk+OUz+DfHDmmBZHdhSw1hNVQgf WXPXlzGImI7rft0Ywh6uzdSvk/hBmYdhVdi2DIvW++rmFeJMXWRFK6n4+Kapcwi7rW+Q ZgLd0z53RKBmNeT1F/O/3vJ6JNf/p5Ms6ZR+wboZ7rWaKvXUKE5z6Rkp2X6AF4miMDGA EQ+A== X-Gm-Message-State: AFqh2kpJF81/OvUuNGG6yu6faBohUCegreZgTjfeOE33FELIQetBEAFw pRazQ5Uz876dEPueyTiVEnNgow== X-Received: by 2002:a50:e60b:0:b0:468:3252:370f with SMTP id y11-20020a50e60b000000b004683252370fmr1862773edm.34.1671636343675; Wed, 21 Dec 2022 07:25:43 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:43 -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 03/18] can: m_can: Remove repeated check for is_peripheral Date: Wed, 21 Dec 2022 16:25:22 +0100 Message-Id: <20221221152537.751564-4-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837821714247477?= X-GMAIL-MSGID: =?utf-8?q?1752837821714247477?= 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 f3ee21ce6109..a43abc667757 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1568,10 +1568,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 Dec 21 15:25:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35401 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586104wrn; Wed, 21 Dec 2022 07:26:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXtJCD6YMqerQhRZt0OU0NR0sG22lWuQ3nkJ8MQYIVSaZ6Kf6K+0ukiDJm7gBcD7qW1KqS9v X-Received: by 2002:a17:903:ca:b0:188:da5c:152b with SMTP id x10-20020a17090300ca00b00188da5c152bmr2330150plc.9.1671636419362; Wed, 21 Dec 2022 07:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636419; cv=none; d=google.com; s=arc-20160816; b=AZmx89AQUzbR4ZvTdheTMLVXzMEyBfZU4Jc+rVP4bl9NftPGxjvDxc5qX6VnqHSRf+ RnQj+LQIdW4G/tTVE2lMw5cjWm32U+TzFbs2Nqr1PNF5hS8EpMgRBQXNP/oo2paYXb8D C0bbvfn/aA0YGXIhmP/TJcOsm0+7LOR9vWfUWYE83qlYrPnC6gI1xRbZTUWnEurb3bqc K5ae4KkSSHDPq6xbqIaABngwJO0WyBUzgFR3uxviuK22XSaEqwAiXuR1r3S94yRM+NV+ IWxnzGDBL3FSiXr15U2EGO1vKRc9fbejPCrU/HX5+xaKrOb0RHmD1RAveMnoqYQ+LG0S VuZg== 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=Fh+i7sl1pIQRS50o8+ESJqbTkr0TABVbPKqpvGqBGr8=; b=xwg7p59JdcSn3sihDhB857AaK3sAd6i1bZh4IuRxzqBz5Cw+Z8c2hq4a22ZqYOxkdW El9JMzmo5eOXx8ogAZAii7vuBTa7mi0DcDVzmZCg/FYnoABslpOQ1SzU6Oc6by7vZAy4 2d+9Utth0fqajENARLJsZT9CVEnjJZQ4kL3mNPMm3xVmmnynIILjFwMrmtvRdwJFuAm2 cfMi4WFnbwVnVhUqgbz3Qt35IwuUzOO1eBjdmec6/GsyJdGQ2xW24bNfhCXPCoIt/9g2 ZH5u4Me6DFbF5mnks36AwCLAZbGHBK23L1phRCdY9GveQ0HSPXRY38KA+0Kux5iWTk2t 2IUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=Fyz4WV+Q; 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 q5-20020a170902dac500b00189feee4923si18461923plx.534.2022.12.21.07.26.46; Wed, 21 Dec 2022 07:26:59 -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=Fyz4WV+Q; 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 S234651AbiLUP0H (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234619AbiLUPZs (ORCPT ); Wed, 21 Dec 2022 10:25:48 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3F0100E for ; Wed, 21 Dec 2022 07:25:45 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id s5so22402076edc.12 for ; Wed, 21 Dec 2022 07:25:45 -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=Fh+i7sl1pIQRS50o8+ESJqbTkr0TABVbPKqpvGqBGr8=; b=Fyz4WV+Qcjmsg/j0ljHqQmf9ASBggxmEprXdUABioB/YrkWMvXLyW92wARKEk7z5Sh PVmefH0BUZ2sLpnpZpjxUO6AcPh/xQIxz+nouiwurmLphKjOvq6jhs3O9ld2nGBof2Rg SO69IPSiiZBHiIaiU8wcRygLOh5Fgt1Fs4+oA4XRBBkr5TKZBBB7ox5obfwgx/7ZqhHs lRoM+7KKOELPyuJFI5uPs49DB979r4D2l3tXaHDCvG0JbAQGEQO72NXSxiCY0G+UWwV3 ynSHEdQ/dn03Ooy4Bw5IntDOfXNjqQf7OD7Sk3mwzFnxyFnFRV1xZE/LbdbbfBl/dZWr sGEw== 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=Fh+i7sl1pIQRS50o8+ESJqbTkr0TABVbPKqpvGqBGr8=; b=fyn0reLY1gl8uxUMhAuuyooDnZFOa6ndew2a2Lja+EXYoQOKbLKj7hPBvIDp2QK1df SqFugBMEggpaEjc6tEdhmHTnSn7rdL570DsKqoErveOWGpHqSmKkHh8gz1lL4lk042YN 4YR+vnk6VIy4U3IvNwJtqKAi7N3N3XTJMkWQbu3Vb/254DXQynV0frznbrbtb54nw50H faQ19mwskIvvO7M3RCudi2HY5QZxHbozNhiXIzUx3QVySibRd8cJ7rMhNGHqtSiMmr4o izuWGnlqe61nvNFEAoVR7ekhL5Mc8zM3wUZZ2eBTftARLDiaVF6BloQkBmBU+TCFNoAn 15KQ== X-Gm-Message-State: AFqh2koEG4wJLmuXHa4JGUzaBNyTdd/0WqSi7AHF3w/ZDiqR5xwul55z Rw0zMz/4Fdva+vpEd2A03k56cg== X-Received: by 2002:a05:6402:1f15:b0:46c:e2f1:3a81 with SMTP id b21-20020a0564021f1500b0046ce2f13a81mr1815011edb.37.1671636344513; Wed, 21 Dec 2022 07:25:44 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:44 -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 04/18] can: m_can: Always acknowledge all interrupts Date: Wed, 21 Dec 2022 16:25:23 +0100 Message-Id: <20221221152537.751564-5-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837829868280801?= X-GMAIL-MSGID: =?utf-8?q?1752837829868280801?= 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 a43abc667757..4b387403a7c7 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1073,8 +1073,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 Dec 21 15:25:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35402 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586148wrn; Wed, 21 Dec 2022 07:27:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXsdQypXWmh7GQEEgY7w5UXOra0M15TEhXhd5AyT8HmRyIamD4CIziSvlpvagVpQl81X7in3 X-Received: by 2002:a17:903:264d:b0:189:2276:30c5 with SMTP id je13-20020a170903264d00b00189227630c5mr2348823plb.0.1671636424193; Wed, 21 Dec 2022 07:27:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636424; cv=none; d=google.com; s=arc-20160816; b=Q4fGWi26908OWo99AOPFIQW/PIFUrMQufAYX21Q2U81QxeL1gaTD8WNslob6fMD7HS IG29WU/DSa9ZCgTbjX0EbKXphpvaMeKWpy37bAehJtV/8sOzWokai1OrtHW0JRjd2CIN 7wZSv4u6xc6fFs/rKV4xktf7vxKQ+YR+kyyHEgu8BXnK93w1vZjbIVFEzd+yWo9NcSDm g54f8CzU7xYezpZ70tHs4xMlguFaU9Zy5L0bD8M4ALYBiP1mJMRN2777sMBeQt5gPxF+ R1FnSAmFrz4UvfRXAcm2yp21imaE9UeEs6K0cePPPkwl73DtZvr2lnirOsVABPhPil2R 2Yyw== 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=XEakEc2TumUj9I0JFZxAmMNH6yQlNW3F3xhK6BoUg1I=; b=V2CyG0pDK0Nx4gkc5wnPpRS4SGDNoly/Ru2Ju/gzEIGGWRGySugKnl+/Y/MCWsmVNj B9chNxbI3YLr3Gj2FbhiraV0iEQTqtGI3YE1/EOO4tGCn2K84MgqOOdfZqfpokrEW7P2 VZGte/SF6TcJD/ZsTa+f6VNemNVL5AyNOWItA2/pN8N0KgDmZQOUFM9hRXeNHDiIsWwv YvjiBuwgp/npne3Y3eqGiC+gxR5n5QkNDF/ctWq/LEf/tQoplQfoCLyWYdRDntj6TsV3 1wI9odPVO7hb+U8+Dcrx7DjX9clStC+Kp1qq5wzkVyva0mn1R8EgrXZehpySlSySyx3O lZAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=Svm6uGAg; 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 j37-20020a63fc25000000b0048441fd28d2si17283123pgi.283.2022.12.21.07.26.50; Wed, 21 Dec 2022 07:27: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=Svm6uGAg; 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 S234734AbiLUP0P (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234635AbiLUPZt (ORCPT ); Wed, 21 Dec 2022 10:25:49 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C665955B2 for ; Wed, 21 Dec 2022 07:25:46 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id d14so22402525edj.11 for ; Wed, 21 Dec 2022 07:25:46 -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=XEakEc2TumUj9I0JFZxAmMNH6yQlNW3F3xhK6BoUg1I=; b=Svm6uGAgnyBswNXuAPBjKuldylKpri2MOc825zRx/pJ/eJTZj57gSwKEb/ss79pB5U e/zJuDh0q2Vzhlx+gtpvX5N7eyndyiprjLqxkQC04/c0ogjoQJpO7/wKOa9aPwBP902l UIbSSEJ0rfvtkY9ZbiyIkfDlhCM/WH5k1ihWXfA7IKV/AcpLgyPcSWwSdMrGItqJwd9W zFBW8qlu+6IpWm8KXv6rzYOKimpr46si9/0zZUegISClGo9TyensAKIdblDapwZe3TEF 2pRPWpV2EYeuEacnUkGVJLUBsrphRoIw2YxJvFH6LzktA/jmlVFmOc7ZDlp8q7kC994q 3TAQ== 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=XEakEc2TumUj9I0JFZxAmMNH6yQlNW3F3xhK6BoUg1I=; b=2UzZsZuwCEs+Y7nR9qzwfllU2Plet8TvM+LvP8kGYVaNZb0ayMBiIpfyHeHlZfv13i aJSmJLl4TSCpHyEHHbJuInQQ9U1mv2NlhNasNvc+4gaJumtvCI9xNiwI6EKrtD9CvEa0 Qc3bal5ET7O04kGDhTIFNgZL1+5ZoF/SR92M04ccibkxsiyXMNRBw8qhzuCwDWuU5Q1R 6dZyW3ZZMkRwuQCumjqktWFhjYQ/80Dkq7XpOJ/hBj1ptLBK9FSL2+h0LIIsXoWOPPzp Y1eRR/zUJqaqHlQFDylNOmoYdIC20rQzIkSrXRnNS4hxh87R4YunVY2P5gR/lc0wWcwB YzoA== X-Gm-Message-State: AFqh2krFff8JYu8UKz9+YmQQIyaow+RZwMnlbbIP4cx1Gq2yYspeuHcP BlQ8j1fADW5AFgUHWE7AagBlUA== X-Received: by 2002:a05:6402:240d:b0:46d:731f:d726 with SMTP id t13-20020a056402240d00b0046d731fd726mr2088485eda.22.1671636345373; Wed, 21 Dec 2022 07:25:45 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:45 -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 05/18] can: m_can: Remove double interrupt enable Date: Wed, 21 Dec 2022 16:25:24 +0100 Message-Id: <20221221152537.751564-6-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837834930078242?= X-GMAIL-MSGID: =?utf-8?q?1752837834930078242?= 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 4b387403a7c7..a76465016e17 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1347,7 +1347,6 @@ static void 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 Dec 21 15:25:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35403 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586168wrn; Wed, 21 Dec 2022 07:27:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXtDnErkBDIp5EnSklXeqxkzEcNspSv/JXtYNd9XTuy2oZtx7Uj0QNU+FHZWRvxMREHwNbob X-Received: by 2002:a05:6a21:c008:b0:af:8448:5137 with SMTP id bm8-20020a056a21c00800b000af84485137mr3227764pzc.39.1671636427911; Wed, 21 Dec 2022 07:27:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636427; cv=none; d=google.com; s=arc-20160816; b=CnFO32OfNlVqIuJQUO0ZDaURASyqQck8TQf/6w0emo9Sey7ZpC/XPNXm4R60I+F2Cj KEEOWGL2/aGXCSrDXNcbpuYow6QTAwEAAZKfD4jQ1gNFGB8FZ0WkFD889tt2uzAFFn0/ AjWvpdcrfnucFYRYc+96s4oJM3/UAKnRiY4NU9o6lSRDf33wj1LbAflXZm75D+zVHkTk qABymxlXIxrxNOKLU91Dbhi9bd1QsLCL/gsQBfwFJ36rKn+t03mNNdkB91QCJrp7/hgF nhUaMEjsR1anZ6JEhilQPa+6a5ikmftGsF5WB71uMwhFMxkWQTChWCM6ihP0lhNVQxsq +Zsw== 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=2pvhSkDS7sLr/yCRVBMsqsSsDc7feD385RgSjpw/bFA=; b=WM6Y9/Oi6tpwHSwKqbHHxnON44Aeac+w99CskLzr06A+xB84ZWimQWz5GBncrkTeaM eWwbH1u8TUpudw3BdnZacyEymhj9hLftb2nCWLFdGsl+SGpHGyJ6eTy3f2IaLBP0jV5Z J6qzTDl8mpCcP/zZHdw07YL7Ks7JS4VUIE+0EqM6btFjmmOUFnCyGwH4AqCAG+ZnP2eN 9m7LijfLIZqTe7tqp+zaruBEEKhFP6SryQzGsZ3DPzenn1IaAs7qtwlizEs28CkvwS3F 7Bw4JMkUzmnv4a/UvPX7Ru55h8wpMYlhzQfZxlYyqpg60LskAzLcfxaJjTj2flB+Hhd5 Wi/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=bkhs3owS; 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 q1-20020a63e201000000b0046af0960898si16304749pgh.625.2022.12.21.07.26.54; Wed, 21 Dec 2022 07:27: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=bkhs3owS; 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 S234670AbiLUP0Y (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234634AbiLUPZs (ORCPT ); Wed, 21 Dec 2022 10:25:48 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0D6C55A0 for ; Wed, 21 Dec 2022 07:25:46 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id e13so22457319edj.7 for ; Wed, 21 Dec 2022 07:25:46 -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=2pvhSkDS7sLr/yCRVBMsqsSsDc7feD385RgSjpw/bFA=; b=bkhs3owSb5fFeZ5stolKBxsxgzclcE1S6E6LBQZCMMFan2MMBBTMhTgMJUAPZD/lHs 8zqKLzUb8t/KkUwk6kcY7mvlHggwNujTO8JAW/Sj5JPBPpXM2NejknROiCRGlZ1psfkn chNdR1RBvED/ZEUXNPHj1exrPPZ65rAmKx7ZiJnGG45IxFGHGDw3pPPLixHA5r2Q6YwE fo9hcMBeVEYGtOYkwOTHk7VVPeHO5//KrN+zTGAGkHlLm27VLrFK0Ky40PM9F+Oy9krI tySiUeRj+TiJUjxzIMyCBWQaOnUzBY3U1F1n5N0j4fu5+I9Lwh8yjbtByzj/lIaIJL4O Ugug== 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=2pvhSkDS7sLr/yCRVBMsqsSsDc7feD385RgSjpw/bFA=; b=2ZYOaFrFUsr+nG63K8848q3AekEsIb71Sn8NTs1ql6lUlOj+mQXW3b21IEPJHfg2S0 6mNAiwwKWhxESe45b8rc7a7teWg/wWTJz9GozBSvPUetUt96lhOciQw9u3xSTIQPSIbk fdeg3v4597qZmtPyczddw5UfYBxDeJ8Nqi58rlX5yGmD7VE+qWPKgKGE8no5/USGwnzY Cuz/7XM9pMDNfh509SO1jwmE9oq4EtYh6HoRPG0lfH5trRC3pnn8kMq6+sFmVcgP1Vw+ 21Y5ekhY0JRHMuaWpQpol4AD759KqK2Z/0ydwg5sOaeKuVtCK8oVdojmzDQHBLiKj3I7 W09w== X-Gm-Message-State: AFqh2kpjMiA/qVRGkoBSPyjAKInMBSmnykfLqkj6YmvdQUDrVZUn4U81 tiOkKCbZ8wIs8gTMSiKc+4FKDQ== X-Received: by 2002:a05:6402:f05:b0:46f:9a53:fdcc with SMTP id i5-20020a0564020f0500b0046f9a53fdccmr2470351eda.12.1671636346275; Wed, 21 Dec 2022 07:25:46 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:45 -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 06/18] can: m_can: Disable unused interrupts Date: Wed, 21 Dec 2022 16:25:25 +0100 Message-Id: <20221221152537.751564-7-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837839422819550?= X-GMAIL-MSGID: =?utf-8?q?1752837839422819550?= 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 a76465016e17..9749a3248517 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1252,6 +1252,12 @@ static void m_can_chip_config(struct net_device *dev) { struct m_can_classdev *cdev = netdev_priv(dev); u32 cccr, test; + u32 interrupts = IR_ALL_INT; + + /* 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); @@ -1347,15 +1353,13 @@ static void 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 Dec 21 15:25:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35405 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586288wrn; Wed, 21 Dec 2022 07:27:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXue/OdPIChoOLEqR7InXwNW483XWI1Z9dMQMp9K2yrmjRq9SzNN8SB3vwE7t3pbXPdWVm1u X-Received: by 2002:a17:90a:e09:b0:20d:bd60:ada4 with SMTP id v9-20020a17090a0e0900b0020dbd60ada4mr1897361pje.32.1671636437780; Wed, 21 Dec 2022 07:27:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636437; cv=none; d=google.com; s=arc-20160816; b=YCaCp/2YcgfWcft6+Uomqjrf6oYh6DhUJueiiVfn+Lzjb3XnxVjtl9oFN41z4Swcxy NCfTJ5bE1koZ/vJm8idozqDDh81LPL4Cq225bicp1e9dl1IvA8XGRBP1BrC3YVJ+nFoh EEYVQ/eXEX4CunLtPa3cEZortNmQ8g555J6MyKqegVQO77cTzRUpO5EZXyEsUnzshnVa HD0urgnVJpgV8jshJ466sHa1a7Dbm2shmEBkTHbsgxGvrJymv0p8SEB1OXj+2qXmci+5 yQ93/OoV++9tz6hoGpHE5NmzF0hEx5ZNXU5MmMNy3dynJpk52RNCbrHg0Jlt5BOXGaGd D32Q== 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=hyl6rPM+iSY41G/DSGtLfPJHWB9hRIbSevUdKHX4ZAA=; b=q2IyuwCpZmL73MiTnN8DaJ92j/7qiGAEaW0IUBaSJGe1hOG0Er3KM4byZdjeSMaQM1 p1KiGdpuSW1gZ7yH3s+PzHUUVpy7M7g/3QymFVs+l0Mp5a/GBc5tPfc2hOrB+axbtgRF uyESSovoJW3RD4O/byoiElc0GaxOWwrIzDYipNc8ZTgKvUSIA4+GcnmO5rBNGyVYZ7rD sBXaW1jVwAtOQxRE/BWKt+rkL0yscF808TQTZr0rx5SVhzs5hzezd2ckhVvzFfq5/Ir2 H+mp+egLtJ9NgREefHtCNrejMfE6R/DOtL6BM/fkbBb5SHH6AKRgDT+qQ/iVHIQGebG2 dm4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=GsSPSftu; 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 nb6-20020a17090b35c600b00225a710a560si723412pjb.73.2022.12.21.07.27.04; Wed, 21 Dec 2022 07:27: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=GsSPSftu; 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 S234764AbiLUP01 (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234650AbiLUPZu (ORCPT ); Wed, 21 Dec 2022 10:25:50 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87A34958A for ; Wed, 21 Dec 2022 07:25:48 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id m19so22436963edj.8 for ; Wed, 21 Dec 2022 07:25:48 -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=hyl6rPM+iSY41G/DSGtLfPJHWB9hRIbSevUdKHX4ZAA=; b=GsSPSftudTd3Pmw3IFMFhTMSnF8KOi3BBUZmMiQYnxSlQWogruWaFF/4GdqBO28s6Z r/aP+jJ0UrYqum+LjfwMuDifjePOXiYmIviOA3sR1tIdUA1vURXafALNfNX6GdidHmSk St6i/EH0dL1i2lAz/FFCpsVhMORUKtknkX7qQQAawhXF7TrydTPnyEeMpWI6r8nraDsm sjbv+XR1grnnfo4t4o9W9dHHhNaZzVuAnmwax8UuOfdY2T/01CubfHp4G3TGXenFfkxQ jN+3pZ8rEMxmn8xygos/0qIhRir42BU+L6Stf866nS7ms8uLBV2jDTznsqoxOvPmMyeg TupQ== 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=hyl6rPM+iSY41G/DSGtLfPJHWB9hRIbSevUdKHX4ZAA=; b=JtKu2nEaG1dJkX2DXelxlVI5SgR910fioqgOkzdqBnQz7PD5Zntqa2JPRYxSxl65PD 94sj6gkEnb/Ijp1eTQpgB05UfdJRkbA7VD64J1FLdIz38btCwcpb9YLZmg3SBuyWfxhl Z41K0qA5MfDB/Cax1JOmYIhNf3jsd5etKjtxFN89doPTVFFpXzf3dW8FbiRv7RlzYgeY FU8LCQDCZx9fwlcADDbKj0Sh9mUp9YUQua1c6ldliqAWsCBjqCq+80r1BzPz8yx3oHb+ EGwJN/Sw0a2UEs9VwZaLYBJVYRVz7NaUixMmi2GyAxvqWGAB2VRxirXkbi8IfKQFHtXv DbRw== X-Gm-Message-State: AFqh2krVT0TWsKTQ3jeg92stF6SCccQHWsc2YYiHvlVOzvow/tJ0Cbxj 5tE6DA2gmmwAgdJwj/2R7dxAVw== X-Received: by 2002:a05:6402:1609:b0:467:7775:ba8 with SMTP id f9-20020a056402160900b0046777750ba8mr2038749edv.1.1671636347131; Wed, 21 Dec 2022 07:25:47 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:46 -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 07/18] can: m_can: Keep interrupts enabled during peripheral read Date: Wed, 21 Dec 2022 16:25:26 +0100 Message-Id: <20221221152537.751564-8-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837849129849592?= X-GMAIL-MSGID: =?utf-8?q?1752837849129849592?= 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 9749a3248517..bcd3bcdc5123 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -962,8 +962,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; } @@ -1085,11 +1085,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 Dec 21 15:25:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35406 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586317wrn; Wed, 21 Dec 2022 07:27:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXuWiED+eiq55xbewudQ//4CYlehn8SMwZc6kUcnpTE5zu5Sfu2MuSkzOznkIE1IRxGmh7ho X-Received: by 2002:a17:902:7c95:b0:190:ee85:b25f with SMTP id y21-20020a1709027c9500b00190ee85b25fmr2135608pll.48.1671636442388; Wed, 21 Dec 2022 07:27:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636442; cv=none; d=google.com; s=arc-20160816; b=x1Wm2O7sAmYjP7MfAGRFUiJ926xsEWKY61lqs81N7TvsqMhinsp1vp1o8IlgT3ToHA LaRMBahe2HcrK12SmYu+vETH04U5r4k5TgJPjiOL6/DU7u/3Xv6ir74AohKFK2chPSGK INV0R4ha+ZvnprWd/hp5KSrWNeLAmEKlllQm928vRqOF5hGP2o5lD6IZWYQoDIouVb1x KuZav7gLBCQklrOJAM6p3+Q0TrvO4k0Zdx8Hb9KPUZc0nsO3WscLBabswsQzBM+nP/LV fqn7rWTSot4EeYD8o3Re2w2yvsKPuvVF033beCM3G6yZFd8H53sQbKSuRTN2wT8Nvpjq RVYw== 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=25T5buiJct4F2Qt5zVUUN9CA8mwo1WMtnKkPLLIV3kA=; b=UEovccrWaIt7C6/5qsJ6WoQfvjoNzBz+kvGDB5PUIO3gwcLkGcy3512dHDPk6VGcIF B7DMVxhYf8tqQIIYLVCKZbBNXMHFeWsEvjxNiakJJeK7orn3cyJaQaOUdVR4qvg9CmT/ MIPAVtHI7cdeh9wc/krM0QTa0gBu7T5mX9YcRpaShD4erUE8ElEFvsCI6QBvTRxaqx9/ ejBLPKpcssNy4EMRQmj9tKPNejHnxS6a/5bnsWZZKpM61tbKGhYs6NiTGCuUsljcypk2 N3TpU9o2500nUWnr3BEWm+PH7PXRJhn1YuRd8S9wR6fzGifnH7XWJX0MhcbJXp1I0e2b ywWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=1c8AfhC3; 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 u17-20020a170902e21100b001897a8ae7b3si15593406plb.296.2022.12.21.07.27.08; Wed, 21 Dec 2022 07:27:22 -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=1c8AfhC3; 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 S234770AbiLUP0c (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234653AbiLUPZu (ORCPT ); Wed, 21 Dec 2022 10:25:50 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A9BAA471 for ; Wed, 21 Dec 2022 07:25:49 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id m19so22437030edj.8 for ; Wed, 21 Dec 2022 07:25:49 -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=25T5buiJct4F2Qt5zVUUN9CA8mwo1WMtnKkPLLIV3kA=; b=1c8AfhC3Ur9TqK1Z7HDC/dZOmCzNppS0f7O/CcrgO2/LQ/+vijBcIdwQfQ6Qo45kYG 5WE7kHQv6QsDd0Uq0NQ4ahbqz9iG88Gc5xlruJpSdUIq3kPIzqWFa3o6hqpr/KbLUlf5 /mgOQqbdxjH9H8BWr7Npz4LwNubw98FKQoLFciUVupsc1REtrExj9Jv3Zv6A/sLghqkI KopXHmPu1VX+N8H3uL3Ay6OUJyZOJgyZrD8mfx7+lTVS7qUtbsqu97nj09sxa1Ellv+x l4ysG8Gb2MYN7xwxly0O6bLfiI71HSGh9FY0s2xPfA8B2sTbhZ2C3LTaeLkdBI/NLd9b SxfQ== 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=25T5buiJct4F2Qt5zVUUN9CA8mwo1WMtnKkPLLIV3kA=; b=EZOamDeE8A2ELAdsrmoocjpzjAaz5YKt+aAw6V+kWQ2DeMBjftn5tjte/4majiq54x mo5STu9TRqi/hDWuPCFEOhJLRIzIqzWumoNC269RDEpD8bD6k1rWHfMa9BjJanpv2ytQ +U+JJ6ooeOExaU/RYHyIuJ/9Jo3aN7JP4XAjV5Z3HX4GKfP47G5KrBrWL8d1vXmYzRm+ Ee4r1cAcIGQLEVLUDut2RLmzhy2qYX55rKCzn2IzQnNnHTJ2+f5mlseXIFEw+Nd3QzVM CvK8ep1npQqZ+rnpqXeqoQdF34d5kGSFKyo89RlYKfjml4i6qKXRJ65CGsUk0Ab61Cbd gQ9Q== X-Gm-Message-State: AFqh2koGxZjsUo8yIzHuINw7PE2zhyHLfaJsGLBMOMbBNR8yaJyhyBwi ch5tptmF17rWvi4XqFeEZvjlJg== X-Received: by 2002:a05:6402:790:b0:470:1e5a:a333 with SMTP id d16-20020a056402079000b004701e5aa333mr1648304edy.34.1671636348039; Wed, 21 Dec 2022 07:25:48 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:47 -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 08/18] can: m_can: Write transmit header and data in one transaction Date: Wed, 21 Dec 2022 16:25:27 +0100 Message-Id: <20221221152537.751564-9-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837853976630264?= X-GMAIL-MSGID: =?utf-8?q?1752837853976630264?= 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 bcd3bcdc5123..9b5ad222aef7 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1657,6 +1657,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); @@ -1696,12 +1697,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 Dec 21 15:25:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35408 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586379wrn; Wed, 21 Dec 2022 07:27:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXubRtbqUScGYztxQgQsEiLXGseK3GA4FCgbN+hcE3Xf8jdNKA7cYb0n9WdX9rGBuzi36kyJ X-Received: by 2002:a17:902:e84c:b0:189:340c:20d2 with SMTP id t12-20020a170902e84c00b00189340c20d2mr2597175plg.23.1671636448946; Wed, 21 Dec 2022 07:27:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636448; cv=none; d=google.com; s=arc-20160816; b=mPDbzacz18EADi1K2X6u5/zNt1bRNYbBZuYk2KA/bK2kjmMvpyssXFHU1GAVJES4CV N74KJbWJk8+X8XGBpmaPm1/lp0Fdvt/cu9GbzII1aYtAOVbQJi8ND8UVrdgkOvMow5av Gwo2tjlr0AnirnLtzCdkoQsjYFTgsCHw//jaSfFhvjGV3IiQ8DkOW4ICZjvNf9mqsiXz goE5Um4juL+/cLnK8mWSbBUc7c0sYL8uQa2aX7B2XP4GkzzOMkZK3DBFaqgl7aWThSXK /aEJ16JiCgV2AuEmIwZNZr35xSosB2sHjfA0qasU3cxWkrdkNJsYekKFa50XCOYuLG9i 2U4Q== 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=ESQGtd3G8sdaW8PjvebdJG0sAEuwFJzA4JH+s3KzMiY=; b=hIMJM8MZGiJrm5xQW+W97qdOmEpIr8XtKuYPYs0FAovaJeKxMdL7S33xhjn0p/ww46 Tie5uZ+K9kjoGPtjpCPv6E9CgURWaIu2oJYVodX9YCIPUkD6dZNbznz6qPnUvioRaR7s 7WbU2jeDES60h0jQv9x+5f3RPA/lzSzShdCvwa9hZFsQrkYD+h0jynU0kNrmPDlmaDuB sFKbLpjqMD6VuzL3TJeKiacyqr3KqjvlXR0cidtS7fh+ukU3t1nc4/UuId2dozSjW/el 2sa0TD5/8NljdL0J1pI/FapeCTqzCkkhVns00BV+jbaASEdgILNjYSRgOSX8e8uUBDm5 PfFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=55Qo9k3T; 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 x21-20020a170902ea9500b00189d0fa14desi15531071plb.620.2022.12.21.07.27.15; Wed, 21 Dec 2022 07:27:28 -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=55Qo9k3T; 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 S234614AbiLUP0k (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234662AbiLUPZw (ORCPT ); Wed, 21 Dec 2022 10:25:52 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CC3E6336 for ; Wed, 21 Dec 2022 07:25:50 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id a16so22456325edb.9 for ; Wed, 21 Dec 2022 07:25:50 -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=ESQGtd3G8sdaW8PjvebdJG0sAEuwFJzA4JH+s3KzMiY=; b=55Qo9k3Twc+84P3Y9UOgr69jkxGWxW2fbnPiMqYj7vchsGhFhbgpMlN9hMfhsN1HFU Jo0cOvCfq2KVf/iWA6KFS4T8N1p4wwllBMAnK7CQcS5PK60ej+YQMK+VZGgKROdfs5aa Wxdbjb9QxNI+kPMl0UraudiUiBu6BKEcCvKcIDsUNy3AlMgF0Gaee4AqKQNgtNSnwTYg lppI1j/MN47k4p8YDbizznSNG0HbDH1GoI7NjEA6TWC5/iVvpnVZkFDf7CdDNFB9EcSX RziafkmM/sPpDhJus5U3Ix32+GFvulBzaZweagl3u2I+O+Bx4xtFei8X+A6ujKQx3V7h t4Lg== 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=ESQGtd3G8sdaW8PjvebdJG0sAEuwFJzA4JH+s3KzMiY=; b=h7Th1hHWWGLSJ1HmVvizAsAd7NCcewoLBOyjgPXQWlK8Fxwi20P635z85qXRGGFFX/ u+szX/VM8XLH198nA57H39tUJGipeLTai4hl2RyaTz8oD7APruU/tvIe3L4HaIisQEfQ ge0IcD2u8Q+FOShBHLCeDuem5HGwt7CwrQMx5y0bFNNpL3MnftBq3OAFMnrSacj7L+Je +pn+oZD0NNsXuJ7Y6xIpo5p3rqQhf1P5sQBovGvaayiKiAM3V7MkIQfNULnEVokE28O4 DdcTKRk3E938GC59aBk8rD10dv2TAng97/vaTj5cRJnGMO7Meh/hitpp0acQNGxDAasB hJMw== X-Gm-Message-State: AFqh2koHlxrFSM2myksDW3oQXccJTXaAqsLQibZfnK3DnmhFZU3Mxwrt jA3SO4CLlDC1zctUb5tq/Zm5yA== X-Received: by 2002:a05:6402:4141:b0:469:ee22:d97a with SMTP id x1-20020a056402414100b00469ee22d97amr1846383eda.32.1671636348916; Wed, 21 Dec 2022 07:25:48 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:48 -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 09/18] can: m_can: Implement receive coalescing Date: Wed, 21 Dec 2022 16:25:28 +0100 Message-Id: <20221221152537.751564-10-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837861424997297?= X-GMAIL-MSGID: =?utf-8?q?1752837861424997297?= 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 9b5ad222aef7..2e664313101b 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1060,15 +1060,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; @@ -1083,13 +1123,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; } } @@ -1125,6 +1169,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 */ @@ -1258,7 +1311,7 @@ static void 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); @@ -1302,6 +1355,7 @@ static void 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); @@ -1360,7 +1414,7 @@ static void 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); @@ -2030,6 +2084,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 d2c584232c1a..4943e1e9aff0 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 Dec 21 15:25:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35407 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586352wrn; Wed, 21 Dec 2022 07:27:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXsfwVcKSTnDknDCsXfCtZDufzYkSDXS8oPmUB0COi2vGs7aLCUDqutl3gQ+MbyvhobKYdw4 X-Received: by 2002:a17:902:e1d1:b0:18f:af65:307e with SMTP id t17-20020a170902e1d100b0018faf65307emr1713586pla.38.1671636445342; Wed, 21 Dec 2022 07:27:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636445; cv=none; d=google.com; s=arc-20160816; b=VU7huuhKRNRQQpF539nxS/UxZiJ36CMcMtmaO0X10+HRvE7POn2Ujssaljx2wd+SOE qX+WAW0qjZFN8SIo0Pib1mx/nPm6zf5HU6Kn9Av3XYUaZlS6tV0U+sbAaxpEGYUZlx+Q mvDQ+qx+ICnfmgxJB6XXT3ySzuTKeNogxgWkqpr3pvk6VUxfm9iK9WBBezXZoBX1NNko 2hA8oDVnnK9s4RDm+XrycyJq/trzjIneUnbi35gf9715uBjSjNcu/S40WPeSM/8I2oqT D+/p9fTd5wPY1Wxg9qrUjqL4m6MxL/vuJ0Ph1TEi/wXtY5YKN+6T/6ulHCx2vzSqfYQ1 ImiQ== 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=vIiue0Eegphd4TqHDxcJLHie9gRriJxojR2XQBDT6w0=; b=Md/iDfZteo3Qy2sr0d+YkXGPC/PqHXSxPVkKaEjgMv2r1N5mdqQdp3yBRMGMW5qFfi w+h5yVi+QHC/eqQd/TMEahNaKF+dMqrwFXKXBXlZ9ov6xZXxh+wTkzrz5FLbrp/kP+QF V3JXeEKQ4bsEcD89E+LeoeJK96wDaS7TMyisEiMUrMTwv6pIF/YrKamBWmZDQKlY89h5 07yqNS7lKFaCOtgOIYqYn8ittRFIFeFCBVRaGthq8Rd7nhw2tX+DLsDRgW8O+Z0Gpz2b LFuNXv0LcLgQ0UXBaQfI4dKM4kZr2+kMM8ziXQxTxpo+Jl4n18Eqt2iKVSU1KYf46Gk5 GzTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=P6uN06IH; 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 c3-20020a170902d48300b0017f61ac5a53si18762494plg.111.2022.12.21.07.27.12; Wed, 21 Dec 2022 07:27:25 -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=P6uN06IH; 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 S234777AbiLUP0f (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234661AbiLUPZw (ORCPT ); Wed, 21 Dec 2022 10:25:52 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CD52DFB6 for ; Wed, 21 Dec 2022 07:25:50 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id b69so22461530edf.6 for ; Wed, 21 Dec 2022 07:25:50 -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=vIiue0Eegphd4TqHDxcJLHie9gRriJxojR2XQBDT6w0=; b=P6uN06IHWaXNID+/R1r/6/a5P1HuWXlqwa5Yg7oJS5DlP068fKhkZ3SwKOIqp3F/GG pI3dFE8HWJICes1ljhmq3lEHlMNI+RRI/B/nfwhj7pydJ2/gI1ruJvtkFOVGsDR8IR8G Qu9SopBKJJeUHeAyQMuB+fiUkR+60O39luRPwP/arM8BnMGlETYM1HpqwAz8XSUeEEbh mXTRQzYqk3BeZSgujRIqbYrBkNMaewLo9KO2/c1HFnRhNTfaOlfbhtJAyAQSlPC+VkAe qzaFnRiICuWeXycPMtZKcme4Lf6MXDxNggPuHp8bzUnNk0WdtbUB7CRBr/zqT3G0HgzX oVBw== 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=vIiue0Eegphd4TqHDxcJLHie9gRriJxojR2XQBDT6w0=; b=6ZaLBdQc8krnkkb3rmBOC2i85qCkYBl1Ckexau/FRQXQTsp/XDXLvpGlZ1Gp5kNQNC 157yiJ/M+tk6ijoInTXrrfLT6WcxtKc13tAczUzz8nP+LUQhQPUog9DuL8yq7Ik7+jN2 q6nkEA3BkgmUXu6HixQWFdH8yh5AMDlxZmAB/TBKXiQCnXmbiwBJ64mwOvdVPhJM0Bzv bUhM2f4MLpy6WXM5Jk5rsCl2jgyK8fNoaUDoADwYVk3JOKaqn4Jcp3agAxwYn5in54dn TfNPgxHyXt9PjGTogjXnmU2Oe2zrkRQWvLJ+CuAt36IF/DyLIRyonNkErku8OfygkR6K 0hSA== X-Gm-Message-State: AFqh2koP1GpYeT6U/eVlJ2/xWIv3By21wBUIZUXLow1v+wNtzw2pkFpZ HUYxpTf34xuL4VRIllaxl//DFQ== X-Received: by 2002:a05:6402:1055:b0:467:c3cb:49aa with SMTP id e21-20020a056402105500b00467c3cb49aamr1846132edu.4.1671636349931; Wed, 21 Dec 2022 07:25:49 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:49 -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 10/18] can: m_can: Implement transmit coalescing Date: Wed, 21 Dec 2022 16:25:29 +0100 Message-Id: <20221221152537.751564-11-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837857308686718?= X-GMAIL-MSGID: =?utf-8?q?1752837857308686718?= 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 2e664313101b..a84a17386c02 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -254,6 +254,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) */ @@ -1070,7 +1071,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); @@ -1079,21 +1080,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) @@ -1148,7 +1154,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; @@ -1309,9 +1315,8 @@ static void m_can_chip_config(struct net_device *dev) u32 interrupts = IR_ALL_INT; /* 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); @@ -1348,6 +1353,8 @@ static void 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 4943e1e9aff0..62631a613076 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 Dec 21 15:25:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35409 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586701wrn; Wed, 21 Dec 2022 07:28:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXte8WnAM47+5huO2x+h9PZkKnMSVUNLkE8W9zB6G8CFngfRvfhjw6JQaD1EKDNwHOI2YtIu X-Received: by 2002:a17:90a:4f04:b0:221:4116:deb8 with SMTP id p4-20020a17090a4f0400b002214116deb8mr2564677pjh.14.1671636487907; Wed, 21 Dec 2022 07:28:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636487; cv=none; d=google.com; s=arc-20160816; b=gTXpD2ahgCd22JKWIwTtfSLPGMd8W5mIvPtzXMxzhPoarAPBOZ6Mek+uIO6SgBX0C+ 1cLXSgXNnaoqoDWQ4FwsOk9MxxLo9z/K5wp/6YgXhjotj9vCcXicHOrOvec12hdPQkJX 20Tmy06ByxcXs4nvLuqJzmQOMJwE5Ac7Kigu+zgbKO3W+RUDasdWEgcdkR1lwpp1JiW5 fT+RxzRjPHjI6HOWkHRX/YuR36y8Ar88A4asahfqpxktUq9k/YV2bRVOCIpYD/m5934m 7lJfH9RwQZrDVLkr1gsQb8packPW5lfMFzuYjeU5/LgKRbNqIVuooHuVK9nGlZw34WEh /Haw== 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=7qkv359vs+V03J9W3PEiKayIw2ITJGoxZQc1nNZiMa0=; b=OXVMxhLGMfDpRT15/+egWV/XhUENF5ec4OF4nqo5vycASVy5USUTcVst9JhFbWm+7t tKjhFLJJylONfheiD1hQRf3TJZqoxaDbvWuxwRTgMk0kXKk/Ik2S8OW37VXI0ZsSSspF iDMizVSZ+Jt3BBAjdn2ek3Yuk8Ju8e8Wb0SnfnXgbKt/HCYi+N8rhSHO+eRX22XxjjHg YH6BxYDoC8Ufe86GbazWyJCyqVBK4GJMykAe71CoPmN9aDCdLrMdk7e/Bc3Ei4jFSIOB gLRtTVyVFJrLv17XFw924VfWBIcfKp8Q8S/9EJyQLp98VwSZRKN/LXA/bibz0D4ng3dp Xm6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=jYNtoHPQ; 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 rj4-20020a17090b3e8400b002198e312fe4si2049708pjb.30.2022.12.21.07.27.54; Wed, 21 Dec 2022 07:28: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=jYNtoHPQ; 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 S234707AbiLUP0y (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234686AbiLUP0A (ORCPT ); Wed, 21 Dec 2022 10:26:00 -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 6D8B113CE9 for ; Wed, 21 Dec 2022 07:25:52 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id n20so37744798ejh.0 for ; Wed, 21 Dec 2022 07:25:52 -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=7qkv359vs+V03J9W3PEiKayIw2ITJGoxZQc1nNZiMa0=; b=jYNtoHPQcv86qHwAc21NMAy0uCh7Ev9M+xF1Fue6qX2ybYd0A8C8fREC9nPRZ7fjUo CGUiEkYVTrJ3btOpVADkOwzwnFf67C9ASyUksqh4gAfYBDjx7wdLPXvpeQBw0VJVsN16 ELVE3/C5wqlk57AkAd+qfO7FkpSyM4f/BsHuqEinUeBVUXSbKbS2wbQttQP1pVIvNjbv y83XC2gDs+NbSk1gAkrhJSEXO/SpWhr5Yk8Akg/mM5OwFOWRSzPeh6RmDLfRh7MVFUh9 juTVAR7500B02t3uia+waPRYzIZIoGrwMexI+TZEZkfNsLzDY3CkEpHn/l+vQv49F4b5 0V7Q== 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=7qkv359vs+V03J9W3PEiKayIw2ITJGoxZQc1nNZiMa0=; b=7qh6YgiSlYNfCE7kgM9Ttpe8fPlopVdanDYuIvoTvlyrozJxSGnLyJECOPa3zr28Q3 OeCanAdZPC9EpM57/rq4Xv24JXhbwFOuC0NwRMmU0J2yJuWXZy83KVq4FN2wHsGqo80c CGvE7adh+Ugq3fQkNqgbi20e5kscgQV9YI5MK825u9ZtpgtzMR8GuaJXspeAWSRCtNcH TEB1J/CINUKTCWcNzdhIo2H1+12ADV5aVOlK6WJhSJDYiNIInLrbcenRd2Mu5Cs9EafG SAbyNiEn+CYwRvZM6Zrw++ZaBStyjCYv093fQsVS6ceMxzmQHQY9rc6g4UOwuuu3ZHYq HQPg== X-Gm-Message-State: AFqh2krbOLMB1c2jiKeVLxtHA8UA43JwUnbaV4OWSxGl2gU+CjsIXvad 11/ImhLvPkiEwwaE5PLaLEEojQ== X-Received: by 2002:a17:906:30d3:b0:838:9b81:1c98 with SMTP id b19-20020a17090630d300b008389b811c98mr1648212ejb.1.1671636350915; Wed, 21 Dec 2022 07:25:50 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:50 -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 11/18] can: m_can: Add rx coalescing ethtool support Date: Wed, 21 Dec 2022 16:25:30 +0100 Message-Id: <20221221152537.751564-12-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837902171435114?= X-GMAIL-MSGID: =?utf-8?q?1752837902171435114?= 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 a84a17386c02..4d6fc8ade4d6 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1909,8 +1909,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 Dec 21 15:25:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35414 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586967wrn; Wed, 21 Dec 2022 07:28:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXs6fvhIR92RAQCA2TPeQlIToj8XOA3ACWTC6g0Sg6f7jsYqzxS1TXLWEy6d+G7NnPR7aLHq X-Received: by 2002:a05:6a20:8b89:b0:a7:a591:4fca with SMTP id m9-20020a056a208b8900b000a7a5914fcamr2699781pzh.61.1671636518928; Wed, 21 Dec 2022 07:28:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636518; cv=none; d=google.com; s=arc-20160816; b=F2QCseT0iy2ere4gZSbALx5FrnUyMtS72Y0iTXNl1yG3OK3aD3fDryj/6ZfZBVLlOC vFe8HWOaZb+afT7ORG/SuSIvF0toHSZx7My/QjtZ+kdSjhANexFCHcpINDgyNp7ZgW7x 6HvoCMokRUEhH2A1bD4oPJCsSMlXN7t2wwArTnbXxqJsA2/zxZGRBIfzCbnq00GsdzOc DKCNfayZDIcZNx+spaTAODn3iUPztkD00hGtNNfRgMe1n376hJWtEnnSf47aEwhUYwhb gRjMVQZ0+BScs7iDydFCG3xU6857EwOiHqaBGiK1ttYqOGY5+vYQ8UdRs8qSLlmpRbLb TfiQ== 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=zaFd0UHzSeYEPzZz7K9tbNkv+WSIQz5WkJ+qjHeZoG0=; b=hp8neAmZlpekInCHCD+XCC+grf/GmtoOww6tV8PyQWJ+Z3ED5c62yDqqnsL9CveyMm Yq0b1A1AsW8y+XvYCjJAu3Jr9hZhdn2RDavkVMipKChGAYEBclvKl+6MIkQqHwZEsk/d HzrMIsqfbpNX/tZyGRSNhuiXqkm1qiMZoALFsg7zNOLhxjJPmN4sHD1IkxhbUixOw5fI HCyoYuKt1s6g6NDVppkrkHIdwS3otgrVtxGKILpxalAlQwTK1287hYjheLJ6Ab3olD3v zTqyFhaVeob/Nch4b9tTIlSocrKw2epCslCmrxxcBlNeMvNTPS48+TSKWdj6160FzR7A 6dbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b="76sOPqH/"; 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 a8-20020a631a08000000b0046edc0aba77si16829343pga.345.2022.12.21.07.28.25; Wed, 21 Dec 2022 07:28:38 -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="76sOPqH/"; 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 S234804AbiLUP0u (ORCPT + 99 others); Wed, 21 Dec 2022 10:26:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234626AbiLUP0A (ORCPT ); Wed, 21 Dec 2022 10:26:00 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D61012AB2 for ; Wed, 21 Dec 2022 07:25:52 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id a1so7452251edf.5 for ; Wed, 21 Dec 2022 07:25:52 -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=zaFd0UHzSeYEPzZz7K9tbNkv+WSIQz5WkJ+qjHeZoG0=; b=76sOPqH/fmMgKEbazcH+Us5Ma/WrgGw2WhMh2Oh4SnBnYPN7eFgp0t3UON5GvUybhR P8qW/TgFWtg6lGMwfIN4AGRTwdt7DUNP1rW570xjnTKeP4tkREOpsVbF/QqgR/GZ6Rfm KVraxRJbkv2q54RucMzujZVWEHoaSAxvoK87TIkyA+c6d4QnWsLZrqBxTLrSaVFyArbH 6wXtYD6quzZG/Uw64VkfNJ4eU+3ynyLczd/DWzEzwTtuHsxzCZbYfauaA9oJLkRs9kMd ixsRxmwhvBMcLJYlOZviydhMCc/gwfbUpKWzNpKvyJ2JP02yEgSyBtzLVrikc6Kau+qV GvlQ== 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=zaFd0UHzSeYEPzZz7K9tbNkv+WSIQz5WkJ+qjHeZoG0=; b=k40sPHcZ1mSesmNM336H2VKeX+SI0MA1iVRa2hv41hq5baue6abMuYH8hJOPBGeJBj UMuj4NktmYrY/CoaZ5m3GB7TXbdgTMvi4IyS1Sv/wgqHtiV8C9/HoqSn3MmfCqgxL+3d hPqdlAJh/o/+2uMS93WKSqUNJtMy8h6zIqmS59Pz+FgLpSfD8v1KA3bQX2uOF54hc8Ks jH26p5suhTtYQcO1kjGu/BKkddcRUUxU0TWx3lGywmD11S/G2VsMTRYZpcmlDNX8D0Vb rhS9EFovTHGJfJoVSfU5x4pUHXO+sta+Qr6gh2iG5i9apcnhu5H6EpWYzpAHb/zR6WPD JCDg== X-Gm-Message-State: AFqh2ko+M4W0NY3q+knvM/pJXDmT1LVjdpnSc1EcGrxT1FizWIEOOXaJ LxuZna4qYbwzQmRQYvNwnng8QA== X-Received: by 2002:a05:6402:241d:b0:46b:19ab:68d8 with SMTP id t29-20020a056402241d00b0046b19ab68d8mr1957308eda.40.1671636351804; Wed, 21 Dec 2022 07:25:51 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:51 -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 12/18] can: m_can: Add tx coalescing ethtool support Date: Wed, 21 Dec 2022 16:25:31 +0100 Message-Id: <20221221152537.751564-13-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837934100913510?= X-GMAIL-MSGID: =?utf-8?q?1752837934100913510?= 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 4d6fc8ade4d6..fc5a269f4930 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1918,6 +1918,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; } @@ -1944,16 +1946,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 Dec 21 15:25:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586786wrn; Wed, 21 Dec 2022 07:28:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXv6Z0XF7PX9u6bjIp05Fuj1w/lW34+whBeQagVF+v2Ux6n7CACK8nBQLspKui8P5ETUWrIG X-Received: by 2002:a05:6a20:a59a:b0:9d:efbf:7864 with SMTP id bc26-20020a056a20a59a00b0009defbf7864mr3346792pzb.25.1671636498336; Wed, 21 Dec 2022 07:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636498; cv=none; d=google.com; s=arc-20160816; b=FWs4EIwLsc7uAZYDZq66rHpPIObni2rjSvtL0fGvZhC/VVbKkfT/c9I4PNB4v57Spo TDIVcpimubL8Djmo0KX6+PK6xEs7lR2hedY5pyvV190hwmL3le55RV/hFMQn7ELJwBBw daxw/LQjkit4/rOSoFx7IHW6/CZ7nE+jwDaRA+Sx+Pg/78XL7XeO97SOJ9ycYbqGPJB3 fOnh3bn0Jh8zthVDQ0by8bK/i9hrj6KPIs6b+YTA3+U062IJ4lV07RpQBDs8V+4ENivr AGHMGhhbHScBAbLxMcWliSf1I1ZG4OzFGZSUjqcreEC290nj3afnegV4neR9P8o8DlnZ VICQ== 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=l41KMmbZ167AwdM3fjtskgTgOQAD6k/gmKgP2JjeSuo=; b=Hiq/wCpn+82hdp7gm+HbmL/OJMokbJ3eDPXJs2PXdj3/CjxEGUkbLmDqj+S4kUPHim UMFMrORpZbFJCM7ksL6uffLBPeg+WdToT9qYsjk9zQAOYD37tiWegPe4VlhgEnZ96r9b UM8cxeJHoDG4GqA0zm2C74vffJxiT8++US2gTh0xRgUj1yHXKI3xKhEYvsupb/T9X7Ws kGehaHOcYyc0VtumJp912qrQpf95uH9Hum7PoVEQScjrkEFaVErftuH4yjrjOniDYdyx 93u9RpoY+Xksf6zppG+JKdyNoTKv124nrEPZJCLP4nED/3hghci4fiQZnApfuJT/26gu METw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=4OB2I3tY; 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 j19-20020a634a53000000b004789808c39bsi16189654pgl.554.2022.12.21.07.28.04; Wed, 21 Dec 2022 07:28:18 -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=4OB2I3tY; 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 S234727AbiLUP1H (ORCPT + 99 others); Wed, 21 Dec 2022 10:27:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234643AbiLUP0B (ORCPT ); Wed, 21 Dec 2022 10:26:01 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50B35164B3 for ; Wed, 21 Dec 2022 07:25:53 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id c17so22426709edj.13 for ; Wed, 21 Dec 2022 07:25:53 -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=l41KMmbZ167AwdM3fjtskgTgOQAD6k/gmKgP2JjeSuo=; b=4OB2I3tYmsRBUZNhYofMKCKmoNI6xPhNUXFV8al/t4QzEmrkbBStccpNMk7ol0te7O +rcqpFb1Ta0dUoXP73+whP8SeKRo0jgHLsXujiIXnvPSreMPugYWo8aLge1WxZss+M+u Bv7C5lu3//oWQ+rXwOZ0MSHUf4d9KoM73wUCwTzJzT+B1Hz/SJ6k19J//0dXJ32Bd5IP 3hlFPuTWTH6iiyVnVKYGMnTo/RkTifZNNRJveyvl23q6XqDay5QtiCV6yGyb1F7JaKMR So9ND/Km44lWkOLdDpblVkSACkAogzIf7jaJE3i0M8aUqBzqfsUXTaV9Vp8Ukg+6mAr1 Umcg== 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=l41KMmbZ167AwdM3fjtskgTgOQAD6k/gmKgP2JjeSuo=; b=TUJDXLL56RXj5re4k45UoE/8HSKmCX39BqTcR3iH2S+l918na37vqHOCblo1xSBB/J qkCIpUdhCAfvDKJgaZoMkysiLs5p5p5m41ltt8sA8wr8gA2dKXOUMOxnec7WCbclzarX cWiF/csCqCsspqFvHJVRqrWV43UtLD8DxdpDNSnNdttHV42WVmy6iEzWRlzERqVvwJk5 r3qVE+o56H/FJV1oQ6xzW3yEA+sIJ0cnHgw3YasOYvfWTUDl/o+qStNyCjCa0r+qHTTN Pa0p19VmTY1RnDLEhk7HMMYMoI3nVY/tjAbluXfhdj+qW3R12++bLUwhlP2mGxMcPyHC N8Ag== X-Gm-Message-State: AFqh2koim8puJsrjr5NW0+TFCb9pC2dCO3sjRLe20hYywK1gWiKfq37g 1PSkCqwZmFk7XCLnTNcZNlS3Jg== X-Received: by 2002:a05:6402:7ca:b0:470:39d2:24c5 with SMTP id u10-20020a05640207ca00b0047039d224c5mr1869091edy.35.1671636352881; Wed, 21 Dec 2022 07:25:52 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:52 -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 13/18] can: m_can: Cache tx putidx Date: Wed, 21 Dec 2022 16:25:32 +0100 Message-Id: <20221221152537.751564-14-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837912528044566?= X-GMAIL-MSGID: =?utf-8?q?1752837912528044566?= 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 fc5a269f4930..5b882c2fec52 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1452,6 +1452,10 @@ static void m_can_start(struct net_device *dev) cdev->can.state = CAN_STATE_ERROR_ACTIVE; 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)); } static int m_can_set_mode(struct net_device *dev, enum can_mode mode) @@ -1740,7 +1744,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, @@ -1773,6 +1777,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 62631a613076..185289a3719c 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 Dec 21 15:25:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586839wrn; Wed, 21 Dec 2022 07:28:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXt6ifx0wIEDZE16X+/+ay/jKM8eH6G4mpzl2qYtylE7CSCey3JQGfua8fTLk6dexbM9Zq4C X-Received: by 2002:a05:6a20:7d85:b0:a4:6eeb:91ae with SMTP id v5-20020a056a207d8500b000a46eeb91aemr3987079pzj.49.1671636505294; Wed, 21 Dec 2022 07:28:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636505; cv=none; d=google.com; s=arc-20160816; b=Obj0XOVXk1DRrf+hIBd0Ul0mSfn1n3rz23oURnKBbA7k6bAQQrb1BHIT1jX7Z2o2r5 yZ26qrP+c8v5DxcV/ebtDxHpfeFXvQNbU3YKN9pvJQZ1DgLfQMzvIkKzB4HjlHjM4T4F wmSKqM3vSGG/YiktHK6o4XNe0oYENVAPmwzurVrKWEEX7z7AxxNC+vjH6EY/BHOUQz0c MXo16JGPf/1yk5tEOw552uQZweuoMxOXtYG5d3v0r4xpwulUaudFMvTI+waTyTEAgdR6 dQsNALqRHw6c0TlnfOfMLY4DtU5Wsx+5nVUOntSSOnorkysjmI/U3no7ofiwhFpu7w8n AeXg== 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=N+abbzg6/8T1rvIqDbVeefSqVLPTDNvtOHgiLP5dPwU=; b=VMRHi8Zccqw/grk/UbZhsq5Q+TxxmjbR1dmWyC8CHcHJifep8A2fdpT6yMwoe86dfp HlgxuN1OLrs2t2vvEXXGJ/GhWoFQ+cZfT+c/McPrn42RvvOLwsdEBcLWx9n9nK8fjGXz vqGMIoTyfJhQA7pPCn6DWtCRZa9iq7j8rqrR/++Qc069gY3lCSC+2S45qMZh/1n48WXg vvYmIz0XcEN9tO4BvLkt+rdS78CVp4ls39T+OlNcn5SkY2f/xKdJPV/OPvfeXN5Hy/4H AglldK4xyLHNSBceP59enfoYibhif/tVhJ2+vP9PQw3NlQ+AyGp6T3BUUYeMtfDP8GRB Faow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=hP5VvX9f; 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 z5-20020a63e105000000b004783935de72si16968727pgh.45.2022.12.21.07.28.10; Wed, 21 Dec 2022 07:28:25 -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=hP5VvX9f; 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 S234860AbiLUP1P (ORCPT + 99 others); Wed, 21 Dec 2022 10:27:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234714AbiLUP0L (ORCPT ); Wed, 21 Dec 2022 10:26:11 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48EFD248E7 for ; Wed, 21 Dec 2022 07:25:55 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id n20so37745114ejh.0 for ; Wed, 21 Dec 2022 07:25:55 -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=N+abbzg6/8T1rvIqDbVeefSqVLPTDNvtOHgiLP5dPwU=; b=hP5VvX9fWLt/WRAXjhsjYhJwQOWhlwNJeWD+NVpUxZfCfPVo5zvX8+PDx5f1bD1J00 Lz5DuqK8zaqVWkhl0MyxPlfLl6hqqWrIiC7ySWisEDg2MApVfTJm6D1lwvL2dd3C+lHc Kt51Aovgjh6mWBOsiQz+yYZ9KIOgKQD2ftzuH5XwBeD4L/zMvLyAgUsIi9bX2D5kZtsl ZYVYymx4I3l5aC4RltMlRutDyicRo+l6EH5WtHt7dFbAFKPdcO5MRjQfiQZ+AsW6ZfGZ sRb6Uij6WU6ObAczUcxYZXVfIHUxIchG7HD3lv0wsX5zzCS5DN7KEOpnAwMgMtwoW204 TuuA== 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=N+abbzg6/8T1rvIqDbVeefSqVLPTDNvtOHgiLP5dPwU=; b=7hNFfRFqEUOR0+XrGsRh6ud+lvmdEPJ/2rCuTz/1n9NHjvVyr0DIH8FSoxCgSOQsUM kiTwjjkSswnzNw7TLiQWbtSqcqKdXxRaaNhaxQRRqdDiN2ZHwoJedGeIv3tphxr9WAAc pSb30iOf3eyfDY06GCb9JrCWb5IsBN7owXYRnrK7beuD1VXPKZDPN4W+YAaRYXAEOv99 eisKKJCpbvWTRfK+DIecpdEYd3zwoaT6RksSf93vqtlq13pq43vxs8jd+aVNtFGxnmIr b/vNsTzL1uSBrhfFgoT6QpMrfEBXITIiJa0mhAOH8bYhlIP/SGtuuMdP/dRRBqALp0A6 Mppw== X-Gm-Message-State: AFqh2kqc7D+4M7F3iymTfmu8DoJBrunh5vAvDpz5we/E1zaKH5Kz/k1I vhyxwAooVx2gq2EKqS+ddObNdw== X-Received: by 2002:a17:906:29cc:b0:7c1:727f:7c70 with SMTP id y12-20020a17090629cc00b007c1727f7c70mr1507227eje.46.1671636353861; Wed, 21 Dec 2022 07:25:53 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:53 -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 14/18] can: m_can: Use the workqueue as queue Date: Wed, 21 Dec 2022 16:25:33 +0100 Message-Id: <20221221152537.751564-15-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837920236505771?= X-GMAIL-MSGID: =?utf-8?q?1752837920236505771?= 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 5b882c2fec52..42cde31fc0a8 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -442,17 +442,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->nr_tx_ops; ++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 @@ -1632,8 +1631,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); @@ -1660,19 +1660,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) { @@ -1796,10 +1794,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->nr_tx_ops) + 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, @@ -1810,30 +1834,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) @@ -1861,15 +1865,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->nr_tx_ops; ++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, @@ -2153,6 +2159,19 @@ int m_can_class_register(struct m_can_classdev *cdev) { int ret; + if (cdev->is_peripheral) { + cdev->nr_tx_ops = min(cdev->mcfg[MRAM_TXB].num, + cdev->mcfg[MRAM_TXE].num); + cdev->tx_ops = + devm_kzalloc(cdev->dev, + cdev->nr_tx_ops * 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 185289a3719c..bf2d710c982f 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 nr_tx_ops; + int next_tx_op; + struct mram_cfg mcfg[MRAM_CFG_NUM]; }; From patchwork Wed Dec 21 15:25:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586792wrn; Wed, 21 Dec 2022 07:28:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXPr5FR9UqqhwPoL3rSwgamRh7STUDXiEL5OmXUyFKvTU0+nfBaGNIyX7jujmWMVnPrJ1s X-Received: by 2002:a05:6a20:a88a:b0:b2:75d0:b702 with SMTP id ca10-20020a056a20a88a00b000b275d0b702mr2013560pzb.18.1671636498799; Wed, 21 Dec 2022 07:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636498; cv=none; d=google.com; s=arc-20160816; b=Ed/DA6blc+1XH7tS5/yoF804+vlcfCPCFmQoGcwqzfhyHoicB+CMzcJSrKOUo8Z5QE zHcZYuk8KxTP3MpVHZoRLDgHWEjnJYX7oWh+filn9QzrZrdBtXgcTTlN5gMXr3hUDGax vFwPXzAXuRitO1l0x9bO03ucAXIrOz0iulFxryIs36jF3Kf3GOth5mqPwL8en3MffWxh +Tdb+5aX4FcPsBDRggxYbFFQLdvag2w2M2a0LNrUdc0NAwD71Ctvo6ZTQXGPHJCbDQXj A9g/kAipdl469VMnFlsk4MCJEqWyIFlI0SG8+TM+6EoDj0K3QFMjIgN4os4vSLKJB6qG Bmfg== 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=r4xNKyUsvaXfBc3iUbNwfQj7kGAAWBTHhrvCBFQZpUU=; b=Gz1KsSiQXN98mx4NcTvR7OaUsze8q+dc1nj3y4L62V54yqLIkK2grvdl1QmKlUwcB8 DqrtoNopNzU8uk2Q1DnraDi5My14+WZK6/k6F9sSVOkHLfE1AL6GDmjdYYdZyenO0rrN RINNftXmENzeen1VUvDGC82pAjsnBN6eXO2K1mV35bfF4xzzog7kvnQldMMh5tp5LPyo UnANHafHLpXz0lv/LeNIhkhxrpPHLdx5b+36MDWutleLtN7sWncIRmxerkp+y6Z4foGr UkYhwbGYeMB0uHNbBK5HPMwrS8GGpQtN97A3fB3QwDaH+O7n1UUmJBL6vHg5KvT+c3kH 9Asw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=52QxhYPs; 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 d10-20020a63734a000000b00478dfd40ef6si17329545pgn.768.2022.12.21.07.28.04; Wed, 21 Dec 2022 07:28:18 -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=52QxhYPs; 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 S234857AbiLUP1L (ORCPT + 99 others); Wed, 21 Dec 2022 10:27:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234713AbiLUP0L (ORCPT ); Wed, 21 Dec 2022 10:26:11 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34C1C248DD for ; Wed, 21 Dec 2022 07:25:55 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id a16so22456746edb.9 for ; Wed, 21 Dec 2022 07:25:55 -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=r4xNKyUsvaXfBc3iUbNwfQj7kGAAWBTHhrvCBFQZpUU=; b=52QxhYPs+F0QvgoHcjHqY2chLRIcLMl5FPqqhjr7XB5Ej9buMkkxpu8jvstKww3K54 XRlrPL2+JVczIXnXWD2+OK602DyWULP+nVUjTvdv6QmjZ5G4AJzZTtD/2OHeOQIBvPM7 w/IRTWH2VKuTb74lJpnZiIg5gJY8Om9ZEiMcshUulCrCV2TEqvfxAuM2yao+jIQ7FEEd 5J9VVmiAP3dC0mEzwPg+6JrgUiq7aOqV36VBIzeXm9IQSeNUE1vbmUjjzuKHznpUxL94 P2hqzIk+NhRZOW49LrKUrrI5OJm6ZciFHb7YJlkaafCpgpU+IH0eY+J27Ivkq3JF32L6 NQKQ== 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=r4xNKyUsvaXfBc3iUbNwfQj7kGAAWBTHhrvCBFQZpUU=; b=pgt8ZdVfQPQMk+Zlrm1sMr9QXHvdtEoAJbJ5pn5ui2zgv3grg29w+hnB0lYIYgdwgq W4GDB2e6DsXjKKChp4fBzB/ZopzsK0VxTICDa2OrpxuFbnljCvPk7aQafQ12mp9ht4rt 3/Zqjz0bgctWWPbAeeSSD1xxIFG5JsjWVnlTDYmToHvF5RwerlkCLQhjnxHBnYtoL8zF c/imS3OrPXSL5qYKJm0YPvZ1CDT0CuSXDjVbGj1gRz7nOuCQNx39QZy86jI/ni1SQ6Cx OCtMiDVAY4x+OERW0Gru010/S2I0JD1e+DsOZ69b1GAflu+Ji4h2Q//8IXQlBZ13JACz VYhw== X-Gm-Message-State: AFqh2koo4fof0L9mAz0onLoP4PqnfkkdDogWBit3Z68WA31CffM5HEWL GHzrhFEyWZCpmZhxEhYXhK74iA== X-Received: by 2002:aa7:dd13:0:b0:47b:a6e:6b69 with SMTP id i19-20020aa7dd13000000b0047b0a6e6b69mr2080871edv.2.1671636354717; Wed, 21 Dec 2022 07:25:54 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:54 -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 15/18] can: m_can: Introduce a tx_fifo_in_flight counter Date: Wed, 21 Dec 2022 16:25:34 +0100 Message-Id: <20221221152537.751564-16-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837913326290759?= X-GMAIL-MSGID: =?utf-8?q?1752837913326290759?= 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 | 27 ++++++++++++++++++++++++++- drivers/net/can/m_can/m_can.h | 4 ++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 42cde31fc0a8..90c9ff474149 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -452,6 +452,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 @@ -1022,6 +1026,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); @@ -1051,12 +1056,17 @@ 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)); + spin_lock(&cdev->tx_handling_spinlock); + cdev->tx_fifo_in_flight -= processed; + spin_unlock(&cdev->tx_handling_spinlock); + return err; } @@ -1821,11 +1831,26 @@ static netdev_tx_t m_can_start_peripheral_xmit(struct m_can_classdev *cdev, } netif_stop_queue(cdev->net); + + spin_lock(&cdev->tx_handling_spinlock); + ++cdev->tx_fifo_in_flight; + spin_unlock(&cdev->tx_handling_spinlock); + 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) +{ + spin_lock(&cdev->tx_handling_spinlock); + ++cdev->tx_fifo_in_flight; + spin_unlock(&cdev->tx_handling_spinlock); + + return m_can_tx_handler(cdev, skb); +} + static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -1837,7 +1862,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 bf2d710c982f..adbd4765accc 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 nr_tx_ops; int next_tx_op; From patchwork Wed Dec 21 15:25:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3586966wrn; Wed, 21 Dec 2022 07:28:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXvTV+Dc09+nd/zCYdqxGgX/i70xqDV2G5aeJfy8vPero6496Yyv+5GXD0rmb55MKzYDX/BQ X-Received: by 2002:a17:90a:138b:b0:21a:dc1:e805 with SMTP id i11-20020a17090a138b00b0021a0dc1e805mr2454384pja.31.1671636518837; Wed, 21 Dec 2022 07:28:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636518; cv=none; d=google.com; s=arc-20160816; b=CRyQ9Lf+w4EPY8LsiOwtSmBpvRnu3NvQ4AntU/SYO/0SjqVElJwEg7fHfUjAL3Vvf2 KxUEKTxjIAMpMghYOvUZilP10Qt/K3ec9mTRDASkoHHyWGAo+eUzo9ekCxV+2BGr28Na JKizQCOWfVg9Tf5FfcQaMM2eoC7cZSiY/+aLBCGVt0imGO1Qpm2CXGuP1BktWE/Zu/pY 3aUmewgR2NmXrOBI4oKyXD4UHKU/xjgUusNgpGDSnjZRELx7zwXSHhBeu6PsgbfN2mwD ddkrWlRx7wgfQs/9sXCaBPX3uO3XaLnlSa0J1rArbdAhKLc5286vp+OxVNYJBXiMnGDZ 3lxQ== 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=gcS8xyo2Dgj5yMo5Xr3Z635PKRFPJKOjB+bkL8yToDY=; b=CzOxGLXxtzcqdVGZwR0m03d2xQs5q/v6ByX3W8qr38DO8Y8WSvnSfspjSDah61h1wn hwLOexXM8zeF6/81umj2+lMRqdU+WvfzF6duTYaQUAc/wCTqL1mQBLl9V1zEbNd6+ryb yK24L+1Ug62nv6wyGzORPZHkTKSFJGmdSpLjBLFoufnttPQ26NjkLIZy1vCTWWCPCoLw 7cypRc7ogs1xajXsVDqY5BfzK/yelzK9gTUr2HARIyIzwNxc9LFoA4q4++m5Ny60oZet LIe/fYfdxq59PayU9zY0CzXwssFo6oQgH+9nKv4I8VyEfnTkZUBLEgo1vnOqM7kZ4IDF AgXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=CFhgTNct; 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 nb6-20020a17090b35c600b00225a710a560si723412pjb.73.2022.12.21.07.28.25; Wed, 21 Dec 2022 07:28:38 -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=CFhgTNct; 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 S234865AbiLUP1S (ORCPT + 99 others); Wed, 21 Dec 2022 10:27:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234720AbiLUP0M (ORCPT ); Wed, 21 Dec 2022 10:26:12 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDA92248FD for ; Wed, 21 Dec 2022 07:25:55 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id m21so11988893edc.3 for ; Wed, 21 Dec 2022 07:25:55 -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=gcS8xyo2Dgj5yMo5Xr3Z635PKRFPJKOjB+bkL8yToDY=; b=CFhgTNctTBBcpXqMmSekbNfE4brWtUHR39nIQAD56RUSUjL+/48SuhLR8BchvSIV1s 6ZOl2Y78SE8EpANS3lUArmq8DmQUFmd+0cPr0s2cgYpd8LIAeUSi6412yP54iShKCeae CX69FgzLGlI+1+fRiFJg5kPaWsAjkmS9qv0dT8z2visvyC/xYgd0je33bNpTUSNxFoz1 zthoX2Y6BI3H7V6KJ7yq8hZ+O7/8qEomECFVJol1hJjQ6cfTzq1yiYveTb//xbwudOHk li1e0q3ro7m6W4OMKGpAZQRsiA3gU/dOF2AK24ZssjnQKyYycCfXO6PtlHesoPIzyuol xrJw== 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=gcS8xyo2Dgj5yMo5Xr3Z635PKRFPJKOjB+bkL8yToDY=; b=w5GB94usXrAA3t4zKCIcVU9u1tDDpLEMjFs8j8nMEKW3bJm3JAptEHRUzYBA2rOwVS 8QvUnpzyaj09LljV4Q0Y+suz6nt4yYFUeLdPq7dugQaT70hesfhDbuQ0R8WWUBJy12Qc OwlW6wUxGe8SU9Z2Uf2YWXerVqE6zarPkMReTKSHFhsz5qLCbu7WgZeyasZJLw8mDnqo uXlo6j4g9R4FCQWRmDR7U7Zg6v6vCcZxxXab44o+ntexDjqb9vJbumxmZSv+3Tpk/tFl sLPb+3KhMPtrzFwyoudseQS8TR0GMwtpodg7GAmHTA2YtFrGn6CdXVI2l8EzBxsTJZmS e8hw== X-Gm-Message-State: AFqh2kpeA7TnwrwmZGZj5j5yWiaq1K72Yt97P5Nc5kD9uET0hh3ZOg9W 8zHYJLnvJEE4Wo3YDgZAh+WsAidyn9InCnms X-Received: by 2002:a05:6402:24a0:b0:467:7c73:4805 with SMTP id q32-20020a05640224a000b004677c734805mr6673498eda.5.1671636355577; Wed, 21 Dec 2022 07:25:55 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:55 -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 16/18] can: m_can: Use tx_fifo_in_flight for netif_queue control Date: Wed, 21 Dec 2022 16:25:35 +0100 Message-Id: <20221221152537.751564-17-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837933948355758?= X-GMAIL-MSGID: =?utf-8?q?1752837933948355758?= 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 | 58 +++++++++++------------------------ 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 90c9ff474149..076fa60317c2 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -369,16 +369,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); @@ -1064,6 +1054,8 @@ static int m_can_echo_tx_event(struct net_device *dev) ack_fgi)); spin_lock(&cdev->tx_handling_spinlock); + if (cdev->tx_fifo_in_flight >= cdev->nr_tx_ops && processed > 0) + netif_wake_queue(cdev->net); cdev->tx_fifo_in_flight -= processed; spin_unlock(&cdev->tx_handling_spinlock); @@ -1167,10 +1159,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); } } @@ -1677,7 +1665,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; @@ -1733,24 +1720,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; @@ -1787,11 +1756,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; @@ -1830,10 +1794,16 @@ static netdev_tx_t m_can_start_peripheral_xmit(struct m_can_classdev *cdev, return NETDEV_TX_OK; } - netif_stop_queue(cdev->net); - spin_lock(&cdev->tx_handling_spinlock); ++cdev->tx_fifo_in_flight; + if (cdev->tx_fifo_in_flight >= cdev->nr_tx_ops) { + netif_stop_queue(cdev->net); + if (cdev->tx_fifo_in_flight > cdev->nr_tx_ops) { + netdev_err(cdev->net, "hard_xmit called while TX FIFO full\n"); + spin_unlock(&cdev->tx_handling_spinlock); + return NETDEV_TX_BUSY; + } + } spin_unlock(&cdev->tx_handling_spinlock); m_can_tx_queue_skb(cdev, skb); @@ -1846,6 +1816,14 @@ static netdev_tx_t m_can_start_fast_xmit(struct m_can_classdev *cdev, { spin_lock(&cdev->tx_handling_spinlock); ++cdev->tx_fifo_in_flight; + if (cdev->tx_fifo_in_flight >= cdev->nr_tx_ops) { + netif_stop_queue(cdev->net); + if (cdev->tx_fifo_in_flight > cdev->nr_tx_ops) { + netdev_err(cdev->net, "hard_xmit called while TX FIFO full\n"); + spin_unlock(&cdev->tx_handling_spinlock); + return NETDEV_TX_BUSY; + } + } spin_unlock(&cdev->tx_handling_spinlock); return m_can_tx_handler(cdev, skb); From patchwork Wed Dec 21 15:25:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3587114wrn; Wed, 21 Dec 2022 07:28:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtTWu3lXCGlI+ZeUUC0GD2EPgBHZHQTK8O6dq7wmiVExxNcJ8YqFnB252xcCqq84mReY1U9 X-Received: by 2002:a17:902:ca89:b0:189:cfce:529e with SMTP id v9-20020a170902ca8900b00189cfce529emr2121853pld.62.1671636537295; Wed, 21 Dec 2022 07:28:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636537; cv=none; d=google.com; s=arc-20160816; b=LQ4hNiJS1/Ji4Z+Qsp2sRRxzclZLViRnp141shr2urabFr5dmbaLMYT4ZML5eFmUwx D+SSiapqnaFp+BOi9HC76IAb6W/9U2uc2b9VtSvf9HbtgktAnaGa9hBUwYJ0Gvg/1aZC wcCbpfpB7cM3GpRXRYYNMzBSCJ6exkGi3vXtQeD7HWNHhdbGqA3+O4AgPWYTPsSB+soh /Mb0Q3NTqdjZe3OhiwXUodDwiw08q+vcZxrqDZlRyR8djrvgyjJO1vpkXY5B4lruXZu4 ZC5FbMa/UP6D49CQl3b1ZQfslYRKY9+aotg0U8NJPGL5Z6N1TqqOG1ciqNVv9mvsNEkL qMUw== 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=fe+MrVyRK0YJrQ5IISCTbJAwTu34d4aUgYLMWTnozu8=; b=yW8gayloFej7QOcFgZK+OSXg5oyIHZlvAf1Pkh3ZQsEJH7zwj9VTJWfHOy7rveIwnS YeK6I54YLpQKXIsbps9w7F+gJsgdvppkeITwVO4wy/R9TJ4B2BxnV+uXbtAlQMyKh4Ar aygAdHAHvKIwR9vY/Y5qs+RfGQnzqCNEztN6XBPwvGFMzfebFkfRqRCKIVyG9VGwEQQq iKdz5zli855DtWThwL/iprNcYUEy55a8OikzEdUpzeRCGTTlT87z3ALJOgYOc/avqtex eLqKEuik4rf6CI2RuBLJyjMiHEjGJEWtjVUByJbuYflUGea+ZswpklsSpVKwfG7ZvUJr nk2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=CDoXZtWS; 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 n14-20020a170902f60e00b0019103c51486si16281421plg.331.2022.12.21.07.28.44; Wed, 21 Dec 2022 07:28: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=CDoXZtWS; 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 S234761AbiLUP16 (ORCPT + 99 others); Wed, 21 Dec 2022 10:27:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234672AbiLUP0Y (ORCPT ); Wed, 21 Dec 2022 10:26:24 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D8B12494F for ; Wed, 21 Dec 2022 07:25:58 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id i9so22493790edj.4 for ; Wed, 21 Dec 2022 07:25:58 -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=fe+MrVyRK0YJrQ5IISCTbJAwTu34d4aUgYLMWTnozu8=; b=CDoXZtWSuqSgf1ZhWX4srtfwzRtK7hLLRRi08mtcnwwk5SpnA6XYeR1tPXz6hwdAw/ jbOdmxt1q/2fsSR2MN6I21zFzf9NZG7/WRpyw3OcgYOQcO21UDLgrsT5Yj3SxDeWUPnR UzsYnjuK40f5jaGu8K/PKhAzZFm8cTXGlVS4G31nD6RX7p8EkQdQBaW9LO0Ji5Gn8O/U IbbskQA0G37X2gVZ+piZ5H2CeqH4MCtpPX69rXf36h7ijU00LbOFB1KxXfkBBGTK729l 1iCbmMtueiiKU3iQe+NxrY+MMZY5tvQZuAOYjM/xUfvkZU1xi0FOl2Bbk5/glMMpPyv8 2VIQ== 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=fe+MrVyRK0YJrQ5IISCTbJAwTu34d4aUgYLMWTnozu8=; b=JWiUNewV3LO4I8YZpx3GKZBoT9nh74oUlyKZWGnxku+Q8kV3zEMOwhTxwnYFOeUOgU wuUQOnx6Z1O9vEZihbBp53kbX9SzqtOAE2yuoS+FtZD0BeUKhcGvpzx6mWernuVPDslc suvKt6Xo//ipMxRzCNFesO9Vogb4fI8KDabOigh4u6Mi/d3qLM5OnoIyf2GNZoLSKsVR i3K8pdiHjD2nj+Jny1TuCRBYEgQjF25k7YESQkZzp5P5stMhbsVgrBVLup+qs8VRpzzS DXGF0uCEEVOpn8TvuUHHiUwfsDp2hk5n+bmxOCHC25z3NjxjnjW85dxS0M7RT/K4FK56 F4uQ== X-Gm-Message-State: AFqh2kpnBPUeuo7BStpeIkSS/Npkbd9kJnDd7QPqzuMDrR9p5jHPfCZE SMAqj2pMjwX4f2THt0ur+Q8hQA== X-Received: by 2002:aa7:dd13:0:b0:463:ba73:9139 with SMTP id i19-20020aa7dd13000000b00463ba739139mr1792081edv.2.1671636357033; Wed, 21 Dec 2022 07:25:57 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:56 -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 17/18] can: m_can: Implement BQL Date: Wed, 21 Dec 2022 16:25:36 +0100 Message-Id: <20221221152537.751564-18-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752837953399645049?= X-GMAIL-MSGID: =?utf-8?q?1752837953399645049?= 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 | 43 ++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 076fa60317c2..719a7dfe154a 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -443,6 +443,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); @@ -988,23 +990,25 @@ 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 int m_can_echo_tx_event(struct net_device *dev) @@ -1017,6 +1021,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); @@ -1045,10 +1050,14 @@ 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; } + netdev_completed_queue(cdev->net, processed, processed_frame_len); + if (ack_fgi != -1) m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK, ack_fgi)); @@ -1148,10 +1157,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); + frame_len = m_can_tx_update_stats(cdev, 0, timestamp); + netdev_completed_queue(cdev->net, 1, frame_len); netif_wake_queue(dev); } } else { @@ -1667,6 +1678,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 */ @@ -1712,7 +1724,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 */ @@ -1750,7 +1762,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)); @@ -1833,14 +1845,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 Dec 21 15:25:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 35416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3587883wrn; Wed, 21 Dec 2022 07:30:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXuGkVc7dt3VMdYGblG3Suie2OAEj+1h2uSPYPQ7zjqKAMdhiqPq+QNkb5wuqffLmlStbs1d X-Received: by 2002:a05:6a20:2a96:b0:b2:5cf9:817b with SMTP id v22-20020a056a202a9600b000b25cf9817bmr4066253pzh.5.1671636630357; Wed, 21 Dec 2022 07:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671636630; cv=none; d=google.com; s=arc-20160816; b=mTQRjjJGYrjRJ7UVy2c/x8A4+n1dbp3lMK5d5WU6WqK1BfCuSTA4x0QG002TLe8CyZ SJpvptpWj81uRwmaXsF/ovN64djbTInuaZAVJhIUkbXpborEcG7hJw6M3SiT/pT7eaXt rgsoPW8BOhf8ZWcIuZ+o+X/1BvspxAc/omUqI2Kzju+/lS3onq5jY91uE7BQznrK99mp LNNlnudu5xneBDeaVA1p33femhmAKxKh05o+mftIEKIEQneON15Wpy9HCDLI9B961std 5B3/qG0ZJNZnBdLOkvjgkfvvxHMCLtTfVAb3MzxdHpPsuvyH3/VBX+K4nbhNIma4lTYx bB+A== 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=xnuTWgs891MmWmFfR4Qv/YHEM/0HR/0MI73lfSbcCY4=; b=c+EFp3XcBDL9VZkPN+jpR4Mf3OyL6ELTfTlNYs0G3zaEVQdbMv3gnYZvAo9i33uSTq LyQCogaZ+xmr3+a5HRDJNj5apPVygjdr0bXFGeTnpbz+ww2jVAkbHsvNf924Y9LlyUMS sk55ZKBNbCYuZPw2sOG9oGZaUkH4OaIZZn3ZdpNjFDRKX84a7yzpYuLW4Cnvea6y7FWM xkT8ajW3+Y7MP1nptTDMb/zox+RZQqxdBVcqd9sdmPDtw9BnCXcbwP7Fk17efYlK9fEG 2xEgu7cSvN0P2G22iL1OrIv/1MS8oqD+wu+q52if4zHhgwY9yXtQqj7yfrGOv5+Io4kX AyVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=aDBvkMWR; 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 77-20020a630350000000b004928a5abf77si1836206pgd.387.2022.12.21.07.30.12; Wed, 21 Dec 2022 07:30: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=aDBvkMWR; 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 S234209AbiLUP2D (ORCPT + 99 others); Wed, 21 Dec 2022 10:28:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234757AbiLUP0Z (ORCPT ); Wed, 21 Dec 2022 10:26:25 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DA3A24F1E for ; Wed, 21 Dec 2022 07:25:58 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id d20so22557274edn.0 for ; Wed, 21 Dec 2022 07:25:58 -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=xnuTWgs891MmWmFfR4Qv/YHEM/0HR/0MI73lfSbcCY4=; b=aDBvkMWROJJ1SF+9K9XlqbliT77HqNm+Vg5LPrt86sC4Ox5IwW9S7z2MqBRFrwymjk x7HxUiz5K3uaKEspxe6fxE7SNlrdB/bWXv09FrzCMWHgpVAYsOeKjOEVeqtMjSWF3Yg8 WX2sngaQTsSIA7AJSuQu38M1rxX8VC6NEPdDFqV3PBRoEvM/4MCvqu7tBTjx93bUpU91 rBt88EiXsD8zuGQ1GhkgCceg4wn015vd7Qw/8VgCB2nLuZxCurot8eNjf4nQErgTCcOP UgvKDKyLu4ksD/vcMo6gQ8mqmaGNQHys7TstbQ9HsR44nEQdz+njgtBBNZ6oQGh2zCUY avoA== 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=xnuTWgs891MmWmFfR4Qv/YHEM/0HR/0MI73lfSbcCY4=; b=O+bZi0GFH+srfKDZjM/52s9FGKrTj3MwbyV11WNb6omex5iQugR1yc7VDrneX8GCUM nTvUzf9watKrfnJYFQ0Pszpsy5g8VmmzZk/X1BrgX9pnlNV5AgLyme4HXBMd+ePIAvm+ HU9gcyyT3WyCGHHtVzarcHLipRQrOyI4GSal+y9aHbY6DHXOgFQ2GUyeFA1xLzGyvxSY 0wzzGDzK8SU8czUS4/q1I+c2xOcbnQtu2j80DShuI48pFDTLwU7DEmvMvXyWKOJnYfd8 XF5mLQkMPndb/r3rGBUfCj6YW2VOKW/KLQM2sW/eG0IV/zxdxeHZT/XSVd6yzuz2YWt0 xVQg== X-Gm-Message-State: AFqh2kqwK04EAIGOa/Cr3yx+rsb15eRpp6EJg16cXjoyIZQr5qbv0RPn JWn/9P9tqwYB3MrPU0hSlvn1eA== X-Received: by 2002:a05:6402:14d8:b0:45c:835b:944f with SMTP id f24-20020a05640214d800b0045c835b944fmr1651513edx.11.1671636358062; Wed, 21 Dec 2022 07:25:58 -0800 (PST) Received: from blmsp.fritz.box ([2001:4091:a245:805c:8713:84e4:2a9e:cbe8]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c793000000b0045cf4f72b04sm7105428eds.94.2022.12.21.07.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:25:57 -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 18/18] can: m_can: Implement transmit submission coalescing Date: Wed, 21 Dec 2022 16:25:37 +0100 Message-Id: <20221221152537.751564-19-msp@baylibre.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221152537.751564-1-msp@baylibre.com> References: <20221221152537.751564-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?1752838051220090591?= X-GMAIL-MSGID: =?utf-8?q?1752838051220090591?= 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 | 56 ++++++++++++++++++++++++++++++++--- drivers/net/can/m_can/m_can.h | 6 ++++ 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 719a7dfe154a..9431735fb887 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1457,6 +1457,9 @@ static void m_can_start(struct net_device *dev) /* basic m_can configuration */ m_can_chip_config(dev); + 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); @@ -1764,8 +1767,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); } @@ -1778,6 +1786,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); @@ -1786,11 +1805,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; @@ -1801,6 +1824,8 @@ 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) { + bool submit; + if (cdev->can.state == CAN_STATE_BUS_OFF) { m_can_clean(cdev->net); return NETDEV_TX_OK; @@ -1818,7 +1843,15 @@ static netdev_tx_t m_can_start_peripheral_xmit(struct m_can_classdev *cdev, } spin_unlock(&cdev->tx_handling_spinlock); - 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; } @@ -1954,6 +1987,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; @@ -1998,6 +2032,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", @@ -2008,6 +2054,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; @@ -2025,6 +2072,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 adbd4765accc..40d90016285b 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 nr_tx_ops; 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]; };