From patchwork Fri Feb 17 14:23:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 58620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp914456wrn; Fri, 17 Feb 2023 06:25:55 -0800 (PST) X-Google-Smtp-Source: AK7set8Fzo0r1mDs3v/Ka4U0PuHwquR3qfxxYd+Z1SV0TRkEAl4KW6G9cjrnp6HVGeHmXjbCHbLh X-Received: by 2002:a17:906:40cd:b0:87b:59d9:5a03 with SMTP id a13-20020a17090640cd00b0087b59d95a03mr462008ejk.36.1676643955265; Fri, 17 Feb 2023 06:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676643955; cv=none; d=google.com; s=arc-20160816; b=eS1KOENN0Qo6RgmgBgnJOSnvcebTlwK25MtYnpT0IKoFwY5i6rNnIie4HtkINMddIP BM1UMm89PDBCxmzFZ81OnDYbPgLdQs0f+yt1kudPEsMBR6ZexQOPTy+iyA2QU/4caOvx +02YocFnCOY63eXHwxBfde7r8dxgoOYNTfDkWFDW2TWxk/jsQaatHpGWVPDEQ/Ti8k3N HI1NBFwfQl4eHg9I9LG0sC5vkAe/FOerYmmNEb3wyZHegLA7MVnEko8IxIapvb8KlwLK ddlASyB1okSy8oXcwusD+Im1K1ZhjXHof6O+8PlVAQ+V+/ta5uBCaKLW8ImYJ6FPsyBJ fMzg== 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 :message-id:date:subject:cc:to:from; bh=dgeZrJmjHgNKhT99sAlHuGsjqjz6662kvBtCRNqu1K4=; b=YJ2m0klY9VtKx6TOTOKqUoJe0BLm6y5/bQYxCSNzC5OkF/4lzP1PzpB/+jBVvNbig3 surN4r53vvcio/2ci8mJcRdeeK28T+19W3WiiyK+YRPJuGwnSk+lDNsCZMj7ZGPiL4in XJb+j1zhBBCKSJi9KLT5eRiHnqqSNaTjFQwHlCXHvXquTxsWRm00MhzTw/8IIYGKS6Aw OujaojSnexp5if8UJpvi55tdpZpKZGA28XeQ8cJ0Yi70GTUqmW2DJPw0zVsHj18mrvjF ArMlAtLkBzfGmTBgjGcMt6/tgmImlfsERn9sP9lRZPTuiDAGD4I/Sp2s8UvTeb+tdDYU dvAA== ARC-Authentication-Results: i=1; mx.google.com; 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 fe17-20020a1709072a5100b008b14cff62fcsi4497247ejc.659.2023.02.17.06.25.30; Fri, 17 Feb 2023 06:25:55 -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; 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 S229588AbjBQOX2 (ORCPT + 99 others); Fri, 17 Feb 2023 09:23:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjBQOX1 (ORCPT ); Fri, 17 Feb 2023 09:23:27 -0500 Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F01BF67816 for ; Fri, 17 Feb 2023 06:23:12 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id T1dgpDEZkPPaiT1dhp5Tkn; Fri, 17 Feb 2023 15:23:08 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 17 Feb 2023 15:23:08 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Vinod Koul Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , dmaengine@vger.kernel.org Subject: [PATCH] dmaengine: Reorder fields in 'struct dma_slave_config' Date: Fri, 17 Feb 2023 15:23:00 +0100 Message-Id: <7ea34ff257633d9a1eeac77dd00616fb24429c4f.1676643752.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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?1758088612006825408?= X-GMAIL-MSGID: =?utf-8?q?1758088612006825408?= Group some variables based on their sizes to reduce hole and avoid padding. On x86_64, this shrinks the size of 'struct dma_slave_config' from 72 to 64 bytes. This should save a few bytes of memory and a few cycles. Signed-off-by: Christophe JAILLET --- Using pahole Before: ====== struct dma_slave_config { enum dma_transfer_direction direction; /* 0 4 */ /* XXX 4 bytes hole, try to pack */ phys_addr_t src_addr; /* 8 8 */ phys_addr_t dst_addr; /* 16 8 */ enum dma_slave_buswidth src_addr_width; /* 24 4 */ enum dma_slave_buswidth dst_addr_width; /* 28 4 */ u32 src_maxburst; /* 32 4 */ u32 dst_maxburst; /* 36 4 */ u32 src_port_window_size; /* 40 4 */ u32 dst_port_window_size; /* 44 4 */ bool device_fc; /* 48 1 */ /* XXX 7 bytes hole, try to pack */ void * peripheral_config; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ size_t peripheral_size; /* 64 8 */ /* size: 72, cachelines: 2, members: 12 */ /* sum members: 61, holes: 2, sum holes: 11 */ /* last cacheline: 8 bytes */ }; After: ===== struct dma_slave_config { enum dma_transfer_direction direction; /* 0 4 */ bool device_fc; /* 4 1 */ /* XXX 3 bytes hole, try to pack */ phys_addr_t src_addr; /* 8 8 */ phys_addr_t dst_addr; /* 16 8 */ enum dma_slave_buswidth src_addr_width; /* 24 4 */ enum dma_slave_buswidth dst_addr_width; /* 28 4 */ u32 src_maxburst; /* 32 4 */ u32 dst_maxburst; /* 36 4 */ u32 src_port_window_size; /* 40 4 */ u32 dst_port_window_size; /* 44 4 */ void * peripheral_config; /* 48 8 */ size_t peripheral_size; /* 56 8 */ /* size: 64, cachelines: 1, members: 12 */ /* sum members: 61, holes: 1, sum holes: 3 */ }; --- include/linux/dmaengine.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index c3656e590213..61e1d1da4446 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -390,6 +390,9 @@ enum dma_slave_buswidth { * legal values. DEPRECATED, drivers should use the direction argument * to the device_prep_slave_sg and device_prep_dma_cyclic functions or * the dir field in the dma_interleaved_template structure. + * @device_fc: Flow Controller Settings. Only valid for slave channels. Fill + * with 'true' if peripheral should be flow controller. Direction will be + * selected at Runtime. * @src_addr: this is the physical address where DMA slave data * should be read (RX), if the source is memory this argument is * ignored. @@ -415,9 +418,6 @@ enum dma_slave_buswidth { * loops in this area in order to transfer the data. * @dst_port_window_size: same as src_port_window_size but for the destination * port. - * @device_fc: Flow Controller Settings. Only valid for slave channels. Fill - * with 'true' if peripheral should be flow controller. Direction will be - * selected at Runtime. * @peripheral_config: peripheral configuration for programming peripheral * for dmaengine transfer * @peripheral_size: peripheral configuration buffer size @@ -436,6 +436,7 @@ enum dma_slave_buswidth { */ struct dma_slave_config { enum dma_transfer_direction direction; + bool device_fc; phys_addr_t src_addr; phys_addr_t dst_addr; enum dma_slave_buswidth src_addr_width; @@ -444,7 +445,6 @@ struct dma_slave_config { u32 dst_maxburst; u32 src_port_window_size; u32 dst_port_window_size; - bool device_fc; void *peripheral_config; size_t peripheral_size; };