From patchwork Wed Mar 15 11:05:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 70129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2262031wrd; Wed, 15 Mar 2023 04:08:33 -0700 (PDT) X-Google-Smtp-Source: AK7set9eBa53TzTe0Lwj6BE70b1vaDULM21+wm3dCU41ogY1gI2s7yByRzFquJbHhAjr+VmmbGrr X-Received: by 2002:a05:6a21:3385:b0:d5:909a:7955 with SMTP id yy5-20020a056a21338500b000d5909a7955mr6001598pzb.41.1678878512938; Wed, 15 Mar 2023 04:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678878512; cv=none; d=google.com; s=arc-20160816; b=mXg52C9tVOCtU1CxWbWg6NCzt7YrUU4D6ojFf4VYU+vTCVvGbXZ2J1vf95ppcPm1St Dwe/lreATBhTveGAVb/0X9lP5Ok+O0/fxrhYidjXIB+f62q1r3R39s39CjS7+BJoQDRb 2mxiGeZCwwu9YqVD8n/UIQjcnD1w8fJbtXshi7TmBRl9kyDIYLMXXtiOznbQxKCu9yt6 3zzbErwuZJnwleg1OVbQOePmv+IWluLKG1N+QB1Ezjgani3yFgVEnFruBpPabkHrYRim qsmAycjhwpDbjMoJ2mDWN1lKXD6DvST2KlsGKuukMDWgl0ptdGtAtKovGih63LqZH9DF qi3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AWzMTugaKEGU24JeDUKp4PyFtC2GqEFZd+tmG3zdkvs=; b=wqM31tBwLOdwOXWJ/Rmk2iGxjClYNIAomPWV1L9EpJpng4wH0+57/sNwbShQyczMK0 6bdM5ZVBdWQvWwa6WIlYf43+KbJggS62dM51tjhNdomTR+k1NP0WbqtLLWV+BMOs2qp8 HFaqEoWcX7HW+dy3Aswtk63yeQQ59gpVGOFdpq+iMHrXXId4UEwpuXggryFBOOR5meFq etil6a1gTIAYEuS/7qOYBcLZZjn8KzGNScCrx8eby+7OjVab8hT4EE5Optr4t/3p4d+U r7g1qzUu3raGTVESOgeM67gcfhPZzCJPWUXDG4ItZFK+EZXNQywCSI0/TtX6UuB4N09C ED3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=cUaxpLaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 66-20020a620545000000b0058d9266a507si4364934pff.376.2023.03.15.04.08.15; Wed, 15 Mar 2023 04:08:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=cUaxpLaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231952AbjCOLHJ (ORCPT + 99 others); Wed, 15 Mar 2023 07:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231552AbjCOLGj (ORCPT ); Wed, 15 Mar 2023 07:06:39 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6511785376 for ; Wed, 15 Mar 2023 04:06:32 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id x22so6809892wmj.3 for ; Wed, 15 Mar 2023 04:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678878390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AWzMTugaKEGU24JeDUKp4PyFtC2GqEFZd+tmG3zdkvs=; b=cUaxpLaDj2CX/ggiG1GSwL+CdNwizAvaSK9qroa7Rui1suiWOwy0JnQ16qOH5qW/2X 5+nTb0rFL5sRjbhFIWk9txmE2FoED82X81p9HVzAo7h7MRdKGOhX2Gh6Gv3f+JyAy0io RQCH7nskO1uSPK4Ff54wAoZ9EXIC1/7W8CQfJyxMYA1Z0DDCdsEFP767DLYDaKjq/Wj1 Zwl96VzTrPMpg8E/eH8FqIYwSMbBgFaaRTtAGvBdBleIB8b/uqd7X69RKNJ3T5lLIpG9 HgsYsojP9loQANiJAwTYfww9BNaAiol1NKXTb3PeXTGoa+uO9yFAUHWpYUPCf0zVzAef 1KOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678878390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AWzMTugaKEGU24JeDUKp4PyFtC2GqEFZd+tmG3zdkvs=; b=gzg6zHnAAgAP4K+0A+WLFBto32O0e1IDxMMX0hFqD5aXtJFgGsKbw3QiyTsipFU9Mm v+Ea9YCpvvGYubQXpOWzcudbXXW9Lc/QUjUOdZbTlvlVV9lG6LWHcF//7z3rz2PZLTia uS977lJcD39Vb1jSdgJRKNb+YGo8yvWV+R0QsO5OJ/iyeu0RK3eRK4KVY3aGCaqZUm40 8WlvlBnih6DuW1QZIxnLqg04G/zERuTDm9ManTc6z3uOq5ZdNdwwDTDI3k1E+8KDlrZp ddYDpc9Rvf8BjtcdOEEWz5NuNbmFEBYsiKFBdAJbYxfTQgxG/YcU4YYMI1ijAmHeeM0Y YUXw== X-Gm-Message-State: AO0yUKVX7YnNaxH2shFQiz5pLNRQzYRqiOvuiqzMHGAvXUs3Hjssc42B QvAqBY//dVQaNtkrYZcpjw6GMg== X-Received: by 2002:a05:600c:470a:b0:3e1:bfc:d16e with SMTP id v10-20020a05600c470a00b003e10bfcd16emr17411428wmo.39.1678878390167; Wed, 15 Mar 2023 04:06:30 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003eafc47eb09sm1460563wmi.43.2023.03.15.04.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:06:29 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v3 06/16] can: m_can: Write transmit header and data in one transaction Date: Wed, 15 Mar 2023 12:05:36 +0100 Message-Id: <20230315110546.2518305-7-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315110546.2518305-1-msp@baylibre.com> References: <20230315110546.2518305-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760431715532254106?= X-GMAIL-MSGID: =?utf-8?q?1760431715532254106?= Combine header and data before writing to the transmit fifo to reduce the overhead for peripheral chips. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index a5003435802b..35a2332464e5 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1681,6 +1681,8 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) m_can_write(cdev, M_CAN_TXBAR, 0x1); /* End of xmit function for version 3.0.x */ } else { + char buf[TXB_ELEMENT_SIZE]; + u8 len_padded = DIV_ROUND_UP(cf->len, 4); /* Transmit routine for version >= v3.1.x */ txfqs = m_can_read(cdev, M_CAN_TXFQS); @@ -1720,12 +1722,11 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) fifo_header.dlc = FIELD_PREP(TX_BUF_MM_MASK, putidx) | FIELD_PREP(TX_BUF_DLC_MASK, can_fd_len2dlc(cf->len)) | fdflags | TX_BUF_EFC; - err = m_can_fifo_write(cdev, putidx, M_CAN_FIFO_ID, &fifo_header, 2); - if (err) - goto out_fail; + memcpy(buf, &fifo_header, 8); + memcpy_and_pad(&buf[8], len_padded, &cf->data, cf->len, 0); - err = m_can_fifo_write(cdev, putidx, M_CAN_FIFO_DATA, - cf->data, DIV_ROUND_UP(cf->len, 4)); + err = m_can_fifo_write(cdev, putidx, M_CAN_FIFO_ID, + buf, 2 + len_padded); if (err) goto out_fail;