Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1335943lqp; Mon, 15 Apr 2024 03:29:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXODfz07qx3xIYb3j1JRFAs9QmcWdwSeRLXVnPQQznKFsN2j0CY9bu3vNaXCCaaHqVN7Qu48mdz1lcGa2nERU/2yqOqGx4p7C7GMoENDQ== X-Google-Smtp-Source: AGHT+IFisMdzJeAxVxCAn7WzfqpB7shos+wEvFdy5/YTSHWJKO51ITMhbBOj9LHfomQ22u8QBBOD X-Received: by 2002:a05:6808:92:b0:3c6:308:a3ef with SMTP id s18-20020a056808009200b003c60308a3efmr9440673oic.11.1713176982839; Mon, 15 Apr 2024 03:29:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713176982; cv=pass; d=google.com; s=arc-20160816; b=uzL7bFt5myDUyueVSHEQi05fOaKmghmh3ZAYGKrNu4vDDpZVT9shY6EdMk2awTY0cq Mo21FSGCKgRoyS3UYcIh1LeCMyWEPQkNv/9JZV1o3DADovHpYdyqKyVrOFP+14+7fW6y A32jGjs5pZJEHs9pCsOeC1ZVsWe9b0UQ7+kIj/Ufsk2zq7Nn4h9KBkUiVrEEo5eGZ3Lx mOD/zxnwUipaQtqc20y/Y7FsLM5ZSUCeLXrfR+7amHAl7uIl3ic/9qXssn5aVVko5BjP iY92Ds9a2oNCH13LT1/f2KZ8aegMmzJQgE92CEGIfU2ZlzVjB6FSDj5FrLOdJlnkLkr7 WeEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/lehrUz7hWetCgF2KGx9B8DKUV7UgKBSK5jeKW82WGc=; fh=raSaJLBXyjzZEVw5LmIKiBw8y7Rh/zanM+uLRPWZ/+U=; b=DvSAD0FkrmKbBhT8wZhsaCsomzOFPwmtgeW4m6cIs4uPRSAJzYn8UVU/XxUrxvK4KK Mvaau63cw4iQ31tr9qAdwcuX9bw2Nk+6TbUfNZySDlkWodEd3YoU0pXjyMZ8rt5er8uL LvrpELOmMGGTl51dXkyND+6eXFy6fIl2eu9c37mpLcgjctCJlZxJV2xv3LVm3qFMl9gv FvFTcC0v2QMeCKJlO3eJmJlJLoGQ+EIK7Lw92X7gzP5ml1nVstlkFKTpZFexHK5Jzuh+ 0vaNH16xXCPzrXKke8esHnn5/aTcK6d6X7MPv4Ts6Le4xvjx1JDaIzyOVy5XNqNJaYVx uDDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TnH1Nvnn; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-144912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144912-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w19-20020ac87e93000000b004368b94dd66si7663632qtj.717.2024.04.15.03.29.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 03:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TnH1Nvnn; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-144912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144912-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8095F1C2159B for ; Mon, 15 Apr 2024 10:29:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 068E65A0F5; Mon, 15 Apr 2024 10:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="TnH1Nvnn" Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAD1859B69 for ; Mon, 15 Apr 2024 10:29:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713176975; cv=none; b=NjNzfVXnbA13j/spdkMF0o8uaRGnCkf5Ux7WrY9NKe/TIhVj51FS2ZKknLm06E16Ad9xPugZ+SMRHg8odnDfk4vp/HTz8eEMME/mdKy8XRq0wEEEwA0tHaB7ZqoYqxNFvJ9bmbVIP+9FSUr07C+EyeJDFfoKezghFKEuhBwmIac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713176975; c=relaxed/simple; bh=76ZZdVJJ6myI99pZLu7VEcOdF24dR7trRSqFyStvLBY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZwhPesAWXC6rlcPH2FsJR2rDyH26cSt/k++XezPDJjKVhfa/0uErlTegm5EZkY4E+MMkpkPcFU/RyqmqcWCSHNSI5bHJrmA4LU7tJ0TtCxTnHcwkvnq54UEKCCNvCEy64uQh9Uid0LN/b7hWIE5HIL9EwTV2672Bh/uECXexdPk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=TnH1Nvnn; arc=none smtp.client-ip=209.85.222.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-78d743f3654so293020385a.0 for ; Mon, 15 Apr 2024 03:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713176971; x=1713781771; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/lehrUz7hWetCgF2KGx9B8DKUV7UgKBSK5jeKW82WGc=; b=TnH1NvnnIxaa1aZrkObX8dw8NIiaj1Rmw1grGrPKI52mIv0BFOc2hFy7bEYnItBazm AQnSYWFp8sXmabcPFSuWthxFhhRFDYGNNcHu8ImQACehXLUYQs+glWPpJxTEQAFf3coJ JMqiF8vsaijH8H6bBovkK8MM1ALA1z+3Je5Wk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713176971; x=1713781771; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/lehrUz7hWetCgF2KGx9B8DKUV7UgKBSK5jeKW82WGc=; b=u5B7CS7IOQMf8m4n7kzSAnOBdQRJeZ2JhtMtKgzB1IKdV7XFYfBXLr7ZK7gjazXppc YLWqOXANMwRQXCTgSeJxeR8ZcRjv8ba+dxuUXr9g/3H5MEs70M8/TZnZNhviVA7z/Rci 5EBe6cDcLfUbsPuWotXju6PJ+cb2FZyu1gVzXuGqOxvBfDrI8H1d2ygOHueh33Dzu77K M1Bq6UDabUoDkKnb6JtKDhIAi1XqUtpGb8MbeTNWjgBcMxCCmyv5xva9JL3p3FJNnLUm gWihX8B/tReolPTjGOh2Pvl9yuWOxOHSTyHJqhfZR7PG6lUdHmHM5YUVPU6MupMidvJp 29ww== X-Forwarded-Encrypted: i=1; AJvYcCUVv9XTmYHY1dj6YezB3ihceKNfULtm0/9e285ykgDRRlCYjRt/9fMbaGMih5WmgnWNKcpoPcNf0URiwJww1tfEjpHeJ4zzJp91f1NV X-Gm-Message-State: AOJu0YzgMOyCY3PLAGAbmqHglTeM7MN7K7fmYIGMgASUC0RJP00K+LyK 1wFpnNKqeljhRD/sKRfiPeJ0zYcoujtHD/62jQYw3qbxv0FSMsjWQMb/6ONd+lTT+ROnimaqFOA = X-Received: by 2002:a0c:e60c:0:b0:69b:2839:b477 with SMTP id z12-20020a0ce60c000000b0069b2839b477mr9769370qvm.27.1713176971227; Mon, 15 Apr 2024 03:29:31 -0700 (PDT) Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com. [209.85.219.48]) by smtp.gmail.com with ESMTPSA id r10-20020a056214212a00b006994394017dsm2437155qvc.27.2024.04.15.03.29.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Apr 2024 03:29:31 -0700 (PDT) Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-69b137d09e3so15460806d6.1 for ; Mon, 15 Apr 2024 03:29:30 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUi9KiTrnJYSqdfn6mcibyyKMnT6f3UHQxypGmdiMCKP8f2um8XHA9gSwaCgQcaB0Fxd8TbTsoqWNFzJFutlWZFDtr/I/61jBarIKi3 X-Received: by 2002:ad4:4f41:0:b0:69b:5476:3220 with SMTP id eu1-20020ad44f41000000b0069b54763220mr9634610qvb.38.1713176970016; Mon, 15 Apr 2024 03:29:30 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240410-pack-v1-0-70f287dd8a66@chromium.org> <20240410-pack-v1-2-70f287dd8a66@chromium.org> <3f8660b0-e29c-47e2-b877-10da058388f9@xs4all.nl> In-Reply-To: <3f8660b0-e29c-47e2-b877-10da058388f9@xs4all.nl> From: Ricardo Ribalda Date: Mon, 15 Apr 2024 12:29:13 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] media: dvb: Fix dtvs_stats packing. To: Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Hans On Mon, 15 Apr 2024 at 11:51, Hans Verkuil wrote= : > > Hi Ricardo, > > On 12/04/2024 17:00, Ricardo Ribalda wrote: > > Hi Hans > > > > On Fri, 12 Apr 2024 at 16:21, Hans Verkuil w= rote: > >> > >> On 10/04/2024 14:24, Ricardo Ribalda wrote: > >>> The structure is packed, which requires that all its fields need to b= e > >>> also packed. > >>> > >>> ./include/uapi/linux/dvb/frontend.h:854:2: warning: field within 'st= ruct dtv_stats' is less aligned than 'union dtv_stats::(anonymous at ./incl= ude/uapi/linux/dvb/frontend.h:854:2)' and is usually due to 'struct dtv_sta= ts' being packed, which can lead to unaligned accesses [-Wunaligned-access] > >>> > >>> Explicitly set the inner union as packed. > >>> > >>> Signed-off-by: Ricardo Ribalda > >>> --- > >>> include/uapi/linux/dvb/frontend.h | 2 +- > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>> > >>> diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/d= vb/frontend.h > >>> index 7e0983b987c2d..8d38c6befda8d 100644 > >>> --- a/include/uapi/linux/dvb/frontend.h > >>> +++ b/include/uapi/linux/dvb/frontend.h > >>> @@ -854,7 +854,7 @@ struct dtv_stats { > >>> union { > >>> __u64 uvalue; /* for counters and relative scales */ > >>> __s64 svalue; /* for 0.001 dB measures */ > >>> - }; > >>> + } __attribute__ ((packed)); > >>> } __attribute__ ((packed)); > >> > >> This is used in the public API, and I think this change can cause ABI = changes. > >> > >> Can you compare the layouts? Also between gcc and llvm since gcc never= warned > >> about this. > > > > The pahole output looks the same in both cases: > > > > https://godbolt.org/z/oK4desv7Y > > vs > > https://godbolt.org/z/E36MjPr7v > > > > And it is also the same for all the compiler versions that I tried. > > > > > > struct dtv_stats { > > uint8_t scale; /* 0 1 */ > > union { > > uint64_t uvalue; /* 1 8 */ > > int64_t svalue; /* 1 8 */ > > }; /* 1 8 */ > > > > /* size: 9, cachelines: 1, members: 2 */ > > /* last cacheline: 9 bytes */ > > } __attribute__((__packed__)); > > > > > > > > struct dtv_stats { > > uint8_t scale; /* 0 1 */ > > union { > > uint64_t uvalue; /* 1 8 */ > > int64_t svalue; /* 1 8 */ > > }; /* 1 8 */ > > > > /* size: 9, cachelines: 1, members: 2 */ > > /* last cacheline: 9 bytes */ > > } __attribute__((__packed__)); > > > > > >> > >> I'm not going to accept this unless it is clear that there are no ABI = changes. > > > > Is there something else that I can try? > > No, that's what I needed. I also found some clang discussions here: > > https://github.com/llvm/llvm-project/issues/55520 > > I propose that I add the following sentence to these three packing patche= s: > > "Marking the inner union as 'packed' does not change the layout, since th= e > whole struct is already packed, it just silences the clang warning. See > also this llvm discussion: https://github.com/llvm/llvm-project/issues/55= 520" > > If you are OK with that, then I can add that to your patches. That sounds great. Thanks! > > Related to this: I added CEC and DVB support to the ABI checks in the bui= ld > scripts. And fixed a bunch of mistakes there (e.g. 'false=3Dtrue' where I= meant > to write 'fail=3Dtrue'!) that made the ABI checks useless. Ferpect!, I will update it in media-ci Thanks! > > I updated the abi/* files accordingly as well. > > Regards, > > Hans > > > > > Regards! > > > >> > >> Note that the ABI test in the build scripts only tests V4L2 at the mom= ent, > >> not the DVB API. > >> > >> Regards, > >> > >> Hans > >> > > > > > --=20 Ricardo Ribalda