From patchwork Fri Jun 16 09:26:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1203463vqr; Fri, 16 Jun 2023 02:43:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Cp42ZVsTnn9ts5Fk1d6c50CnX7u4+MF/Q/FufmQ+2OSb5mle6NwS+ZbAlFif9rP56aut+ X-Received: by 2002:a05:6a20:7488:b0:118:62d9:b0a6 with SMTP id p8-20020a056a20748800b0011862d9b0a6mr1936527pzd.4.1686908598452; Fri, 16 Jun 2023 02:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686908598; cv=none; d=google.com; s=arc-20160816; b=MSfIyQWadzkogBBLQSA5D9BbmJGCRYhKqWBjF8olTuyx7WMJuqCSZkEaXEqon0j/Br sAPnavYtsOXtK7yhJmvlmRh/eJQeT3vHMaKMoOci4Nl/C1CdbIn7aWBJNJiv0fF/wXQ3 ULHOSqrQlEL++OFEZeksKPFvntSdzNMqDPVczwmXMbNfZtA27GqYK3jmuOq+yBPMeVIY EDZHhXhX1WirJjlBNO0RTAFVgihp9XnwTdgqL+4bhdcxaHQnKxDs/CypGRyeSnuaUnoh fxBN1PYM3+P2yvj7ZPZ0vxQH4Ged9g6y/wdycuxBz8zd5zPsgoeI+ww+MpDDU31x10Jk n5tQ== 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:dkim-signature; bh=LZ0ppIcswjunFvqnONfMZ7legFoDPMyJrV2gWu2LUxo=; b=q/4+y0cO3A6EZWwBBWA8Eho1C6SmUPGBDt0jDf9An35Rtd4fRUudWE9A9LlSpxSzGE gchdhiYK6CueAzsdEG4Yf5cx7WtdqTXyL25FuFaWwAoGc0srNtpjpm41F7if6Hj5PgkE u11xUUG0nWDgc4rxZ80nDsXcMnCYewiKOCgmsr6fEuNCBMNpqedHrpqhEvdauTrzd3VY NYHpvT6pc/VwmVWK6Y1GEYFSYpEaNaCJBG8MEnTXF0ldgV1geiHk3qI2eChdg6yxh8lS dfWLYlT9Haq/qrWyJpH1Lr+PDsksOSBoBQNuJgQ0OUeAOFx64p/rSPVt63p5alwT7Umo cdHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CCgVGKyt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a654b8d000000b00543c84bf588si14877014pgq.473.2023.06.16.02.43.03; Fri, 16 Jun 2023 02:43:18 -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=@kernel.org header.s=k20201202 header.b=CCgVGKyt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343615AbjFPJ2c (ORCPT + 99 others); Fri, 16 Jun 2023 05:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344164AbjFPJ2I (ORCPT ); Fri, 16 Jun 2023 05:28:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEAA549DD for ; Fri, 16 Jun 2023 02:26:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5EFCE6147F for ; Fri, 16 Jun 2023 09:26:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05596C433C0; Fri, 16 Jun 2023 09:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686907611; bh=tARQMYG/aYeqmMUAJH7cbPA26P2Il2Rzs/1oa9c9qgk=; h=From:To:Cc:Subject:Date:From; b=CCgVGKytISv+fj1viUpOXb/VC4Og1rkCvfO1nGrZGtrr1hcPuZ0OGg72pWvzllRMt B2i720ZfbsqDU3GVRmN6t7ig12mjc3aT0Fo+p3oR10Nv3yAlD4LtPlTSLUYfYeeg3B bGj3FAUqVSldEwRGDSkJ7bujvfySd2/5hftnxzPLC8DhikYfFUna16dmx7UZzUNM4/ 4pn4P/OsmywmiZ6cw+2KCP0P1V1hlCn42pdDJ//LUDJiUgy0ZD3nx8MtrDgqG2SO48 fmE0/zJZ8CLWyI8+9UTPddpKhqr8Ht40TYTI9yS8Kv/T85fISnMtqW5qcGxic477Hd hB3qSJirhs9bQ== From: Arnd Bergmann To: Igor Russkikh , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Tom Rix , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] net: atlantic: fix ring buffer alignment Date: Fri, 16 Jun 2023 11:26:32 +0200 Message-Id: <20230616092645.3384103-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1768851870669615161?= X-GMAIL-MSGID: =?utf-8?q?1768851870669615161?= From: Arnd Bergmann clang warns about conflicting packing annotations: drivers/net/ethernet/aquantia/atlantic/aq_ring.h:72:2: error: field within 'struct aq_ring_buff_s' is less aligned than 'union aq_ring_buff_s::(anonymous at drivers/net/ethernet/aquantia/atlantic/aq_ring.h:72:2)' and is usually due to 'struct aq_ring_buff_s' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] This was originally intended to ensure the structure fits exactly into 32 bytes on 64-bit architectures, but apparently never did, and instead just produced misaligned pointers as well as forcing byte-wise access on hardware without unaligned load/store instructions. Update the comment to more closely reflect the layout and remove the broken __packed annotation. Signed-off-by: Arnd Bergmann Acked-by: Igor Russkikh --- .../net/ethernet/aquantia/atlantic/aq_ring.h | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.h b/drivers/net/ethernet/aquantia/atlantic/aq_ring.h index 0a6c34438c1d0..a9cc5a1c4c479 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.h +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.h @@ -26,19 +26,23 @@ struct aq_rxpage { unsigned int pg_off; }; -/* TxC SOP DX EOP - * +----------+----------+----------+----------- - * 8bytes|len l3,l4 | pa | pa | pa - * +----------+----------+----------+----------- - * 4/8bytes|len pkt |len pkt | | skb - * +----------+----------+----------+----------- - * 4/8bytes|is_gso |len,flags |len |len,is_eop - * +----------+----------+----------+----------- +/* TxC SOP DX EOP RX + * +----------+----------+----------+----------+------- + * 8bytes|len l3,l4 | pa | pa | pa | hash + * +----------+----------+----------+----------+------- + * 4/8bytes|len pkt |len pkt | | skb | page + * +----------+----------+----------+----------+------- + * 4/8bytes|is_gso |len,flags |len |len,is_eop| daddr + * +----------+----------+----------+----------+------- + * 4/8bytes| | | | | order,pgoff + * +----------+----------+----------+----------+------- + * 2bytes | | | | | vlan_rx_tag + * +----------+----------+----------+----------+------- + * 8bytes + flags + * +----------+----------+----------+----------+------- * - * This aq_ring_buff_s doesn't have endianness dependency. - * It is __packed for cache line optimizations. */ -struct __packed aq_ring_buff_s { +struct aq_ring_buff_s { union { /* RX/TX */ dma_addr_t pa;