Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp257773lqr; Wed, 5 Jun 2024 05:26:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXivjo880eLtW7zPpO7WJSXsZv+tttH+FawDnAhlxEsT6ja/jhPXMgQCADPB1LAKaX9uOfAp+GlnfH/z3zthxZDvqpou6rgoGEohxQ6ug== X-Google-Smtp-Source: AGHT+IHXdaphUWlgxt7BjeyRpdomWsEIflQqkrxpVgXud0C6qtuuBd0Vmlg3EU4aRUKYJiEGfilt X-Received: by 2002:a50:9551:0:b0:578:656b:d287 with SMTP id 4fb4d7f45d1cf-57a8b6a4cd3mr1361695a12.17.1717590384260; Wed, 05 Jun 2024 05:26:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717590384; cv=pass; d=google.com; s=arc-20160816; b=PM/IrKQ2/R8WHt7v38yF16jUI2pl6cMnKeZJfeIhalMyjNLSKBfr/QnTnwiFhCsXEw AhwH3Z3EatCC2B7BQ/1T+JfozvnB+OPZYHf2YzYgDFJRFlJiqPlz8mEkbnREGJw5+iGm PTShrwh3Afi1kuyHibtK5IrL8t5NoDrEYWwhLc7gR3MFXdbFlhiEXODjUPb07HwDt23+ ObVxLM/4hEhkgBXYqyqJSWsQdzT+H83vDqluG5r28B+7DMgwd9Jti+jIvc9VrJEFGNts wlEj0Abtm7RNFO3kDR4FXQofqqx/5ciILvog1N0TtpGJq0cnjUbvj8JJQr2wRvHddtlF t6aA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=17rQdjGRIN2CSga/YFCaGswU6lwvjB6GqByaiI2V+ko=; fh=LS6mvamHJHvSNp6nhzWKoLKhLigQEFnj4tcwNGJXlh0=; b=0WahP0zGKUWkzE5LxvJuIoe6/5qzAr+fMZBsnV67ynes/JwJ+4V2MWd26539ree0mo yKv666WbuOgolobp1gNt960V9oIjgedgNs6XYxdkeBc/mH1+R1JwasA9lgkWBimavNQW bzEOJL/WDlfHybXNbeBbq+tMc66QIGBnqYPMd7t8C7mQX+Dq9Ceo1Q4emiHxuTsPdLJg rXpaJc1800/BnRnxhjl4cN9BBEMLxhKRyxVRX24RcAvrk5awXn/QWFzubj569aGhn1wp gLc+kdZ0xFcqbOQZRab4CzH3ZW5E+qiC70QfrTyXhC6c2nRu/9jMSoRrzp0vGIwZ0s8Y 8Tqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=O3lts7qZ; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-202443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202443-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a76c97c09si2229666a12.133.2024.06.05.05.26.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:26:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=O3lts7qZ; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-202443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202443-linux.lists.archive=gmail.com@vger.kernel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id B67381F253A9 for ; Wed, 5 Jun 2024 12:26:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 327501BF916; Wed, 5 Jun 2024 11:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="O3lts7qZ" Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (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 8B9311BF90D for ; Wed, 5 Jun 2024 11:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588620; cv=none; b=DAaOqCnhzlnLz3Am+STt+f9cx1H57BgRIzd4IFYxqArNxoENXprpl48tJdzxh6++W6/aSmVfCN+st/yEGRBI91C0oQAt/rKcQdvkWrSKjYWdwNIclWur2KjEHY4I36kGiKV/uesBCx+uLkoThqJZWkS1g6SAvvhcK+U09L2WZjc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588620; c=relaxed/simple; bh=UbH1/7grnRdpXvuxHfEUVkrSJnWawHkx/2SBGGKAPgE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M5RC/RwXNLorwHCY6svOtf5I76s+tT7A0F9dawJhiLetI9YxSeJ9mi+61NRg/Yra4fRD6CTU2LrN8UO59Xcf39pHDVdgtvm3ti/dlgYmRZ9xOkoMdpCnV2hreqEQC5aUGz1m/0cQTxuSHH+UFfbJh4BHW+SUl1SCois+o2SxiRE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=O3lts7qZ; arc=none smtp.client-ip=209.85.222.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-79523244ccfso64600585a.0 for ; Wed, 05 Jun 2024 04:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1717588617; x=1718193417; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=17rQdjGRIN2CSga/YFCaGswU6lwvjB6GqByaiI2V+ko=; b=O3lts7qZpx3A1CVGBB5Fx8C3vLToLcJWJxJfxzYvpZO3S8CFQGExq2QEFn01+5qd/w l/+j9XlRduaikM/uWlNxR+tdvTZP1ZqLyT/+IWrZiGk1gUXAnP1KWcd0nSpPtxozFhj9 ruvo9+DC39no/82lSzhiHV4AGGQYWrje4FQHzJyG0Jpoq/BFvD5Rtn6BksZEtGE6yS34 CLFoELN+uHBkym7mVAnxYjCbfucy4THRwYN7yCoGeY9cvBOJL5jm+tSSkZ85ofDnK1Ep yBMh05907+3btuKX60kiTRZfMnzjLleKeJ00LvDI9E5GHrnY3h/Z6VpIIaOhb3rApa+1 EG5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717588617; x=1718193417; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=17rQdjGRIN2CSga/YFCaGswU6lwvjB6GqByaiI2V+ko=; b=HYLpxrsHQRsjzwqi3KgTap4+9usynw1MErbJaETcCKDegW22+2U28i4JW6G3f9dHCL Sby4V7vMESHoC8Qb8ljyrMaDOWxOvOoQCDp/u8oob9IaswoU/xDtF3XBFoBU9X8KimZ0 DHmZuFz7aldCqJboKaxTey8fOCkeQcLRVpRvjErKzH/CVDOygq99YKfmZBhHfc8pwJGa ISthGK4nf0Dya4AD0wpb7kceUZZdyOJRm2TdelO8j/WoE+f68Q8bU68zChNnqs0OsI/w nk4ns5GZbdOF/hOi00DobR3Ez6OPiNsPA3b+lJ76P3pEvPROltueIt3P43JbELye+AOG YBbg== X-Forwarded-Encrypted: i=1; AJvYcCUWhMNTimwNwBwL0dCwEz/p0eL9hHyVZScIYT8ILzCTsVe5Yvrb0i2Y6zHGVRMrJa2/+GfVDBCoOQULTl+u+dJDHjSDVIhNN0bWWnyR X-Gm-Message-State: AOJu0Yw7wbCxT3TgkdzRT5xe4Nn5DtMI+2Y925i1H9dqEkjZ++MKwwuo +8qITv/0yM0DPvh2/IJWhCn0+zHdOjiDuP7CCRCdaQf1a+RodEL2w16dVmgsjxU= X-Received: by 2002:a05:620a:1362:b0:790:efef:af55 with SMTP id af79cd13be357-79522fa4bbbmr417688985a.3.1717588617261; Wed, 05 Jun 2024 04:56:57 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-80-239.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.80.239]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7952b8e99d4sm12315185a.72.2024.06.05.04.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 04:56:56 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1sEpGC-006ZOM-6l; Wed, 05 Jun 2024 08:56:56 -0300 Date: Wed, 5 Jun 2024 08:56:56 -0300 From: Jason Gunthorpe To: Mark Rutland Cc: Arnd Bergmann , Catalin Marinas , Will Deacon , Nathan Chancellor , Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , "Mike Rapoport (IBM)" , Baoquan He , Peter Zijlstra , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] [v3] arm64/io: add constant-argument check Message-ID: <20240605115656.GC791043@ziepe.ca> References: <20240604210006.668912-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jun 05, 2024 at 10:15:38AM +0100, Mark Rutland wrote: > On Tue, Jun 04, 2024 at 10:59:57PM +0200, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > In some configurations __const_iowrite32_copy() does not get inlined > > and gcc runs into the BUILD_BUG(): > > > > In file included from : > > In function '__const_memcpy_toio_aligned32', > > inlined from '__const_iowrite32_copy' at arch/arm64/include/asm/io.h:203:3, > > inlined from '__const_iowrite32_copy' at arch/arm64/include/asm/io.h:199:20: > > include/linux/compiler_types.h:487:45: error: call to '__compiletime_assert_538' declared with attribute error: BUILD_BUG failed > > 487 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) > > | ^ > > include/linux/compiler_types.h:468:25: note: in definition of macro '__compiletime_assert' > > 468 | prefix ## suffix(); \ > > | ^~~~~~ > > include/linux/compiler_types.h:487:9: note: in expansion of macro '_compiletime_assert' > > 487 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) > > | ^~~~~~~~~~~~~~~~~~~ > > include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' > > 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > > | ^~~~~~~~~~~~~~~~~~ > > include/linux/build_bug.h:59:21: note: in expansion of macro 'BUILD_BUG_ON_MSG' > > 59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") > > | ^~~~~~~~~~~~~~~~ > > arch/arm64/include/asm/io.h:193:17: note: in expansion of macro 'BUILD_BUG' > > 193 | BUILD_BUG(); > > | ^~~~~~~~~ > > > > Move the check for constant arguments into the inline function to ensure > > it is still constant if the compiler decides against inlining it, and > > mark them as __always_inline to override the logic that sometimes leads > > to the compiler not producing the simplified output. > > > > Note that either the __always_inline annotation or the check for a > > constant value are sufficient here, but combining the two looks cleaner > > as it also avoids the macro. With clang-8 and older, the macro was still > > needed, but all versions of gcc and clang can reliably perform constant > > folding here. > > > > Fixes: ead79118dae6 ("arm64/io: Provide a WC friendly __iowriteXX_copy()") > > Signed-off-by: Arnd Bergmann > > I have a trivial nit below, but either way this looks good to me, so > regardless of that: > > Reviewed-by: Mark Rutland Reviewed-by: Jason Gunthorpe Still codegens what I expect on clang-17 at least, agree with Mark's note Thanks, Jason