From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7ED58C27C53 for ; Wed, 5 Jun 2024 11:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=COD+QsCIrQgmVgz9vVTZgO8emeAAaPiny9O3ITx7XY4=; b=ImEcFAZxLpyY1J ZRe0iaMuIjon/kjkLyiqXCYbRdOqtbOgP7Jz/4BA0Kod26QYETl66d9G1jx2dxuidfEOaO4v8c2nf 4u1LdQB2HiMSZgAp6zNZvy8o/LPpaxN0lefLQqGg9EWrrXfy2Uc0+IIAljgoItUT9fEbhJ5nTYaHX TvYPpQ9qe/htlVFwAL1ALjBEEoXb2OhqF+DlIwvcSKl4EfYKES4jk31e6nvL6697lCyyLFr+KZkWl ntBQL0RUB/gnby6afNuPKcH8UDKvQS3i2fEPnF7h9Atu5GwuNci0Fsogofs+9LW+Xozj212NzEeBy k4qhPEnOmXR8w/vN/KhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEpGL-00000005oro-1AW9; Wed, 05 Jun 2024 11:57:05 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEpGH-00000005ooM-2hm7 for linux-arm-kernel@lists.infradead.org; Wed, 05 Jun 2024 11:57:03 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-79509b390a4so63615285a.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=lists.infradead.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=kjjl4rZVcvIbSbIozaHxV19oAX5OqK4ZvK0BAHkol0o0hfBLJECNqZdnScOMxeuc8N 62hlOKaF2egIfodSuvilJq1ksPsFVbMtCRnXCy52QuexZpxe+0oSEcy5ObAiF5yoPJaP jz561OqnmnpjvMwZGkUgb/3wuU/i8WvdAOCLce+CzecdkbFDJQt/jFoLd4D4mv/LQ2eh ULSaV2j640ZygKLIDmMkPk8MXXj4JFOcmz3B0hXAqQEn8oGibAWlFOrbe3fWta2WX1Ig WP8egRFj9JjK0OdITUJoyFhdzoy3eLXcg58iuhyy8AIEjnBgYJTuXMtoIijOzFj/J6MJ zcvg== 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=JxojjNYgyLsYzQPFfv5wjnAfH2vMu4ZC9jwuYfiMYnRtwlknkewwn1TpevIw5yJc9B UWJvkBuQmzrC5tAjYtr145FjCApAnhyquP+7zaoTgycxNBNEu7koS4X2wsjQGWZC6ca9 VFhAIC7YhBLTlVwInfVieGAPFguBIQD0FzrPkucqahyJgOEVxhVmJYtDf8tvl5pyAamk FMhsGyUXUTHVMZ0IO/zM0+N2sTUDZ+ZRqlhjftouqa5o98wqPmTAQvT9ixutlJZuFQAV 4SNufYTyT+p4OnLO5k4mDF6Ve3uPNt3sFCiO/00zATt/TWOZ+mBuJPWMWXvOpcDOmcT+ DYUw== X-Forwarded-Encrypted: i=1; AJvYcCWk7E+HbJ5PbnQVf/JIQ+6Ou6JC10wZWfjx0ESLpBZZPApqVY7CJ6iL4CV+z1ORleLRElCwF9JwbhxLKd9HWCTGKh3YyfuoT/sB4MVDOZeJ/QlsOeE= X-Gm-Message-State: AOJu0YxrV15+RozIVA33PtQD8nTCH3LFuEg7sT5JLMz9kP0f2cB7NJeX 69MUoe1qr20J19pFJPOJIPUbLlYHnVPjkOaEAKVYZx3NjYxL3ckzMHFvHBqxIE0= X-Google-Smtp-Source: AGHT+IH87Vgxi0u/6B6nOPz3Js4whNZ+PxPB9EPNZ3t7mrmfAT1RKqbTJL+X2xFL1FK3wwFqMewlsQ== 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_045701_863179_F698185A X-CRM114-Status: GOOD ( 24.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel