From: Nick Desaulniers <ndesaulniers@google.com> To: David Laight <David.Laight@aculab.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>, Mathieu Poirier <mathieu.poirier@linaro.org>, Arnd Bergmann <arnd@kernel.org>, Tao Zhang <quic_taozha@quicinc.com>, Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linaro.org>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Nathan Chancellor <nathan@kernel.org>, Tom Rix <trix@redhat.com>, "coresight@lists.linaro.org" <coresight@lists.linaro.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "llvm@lists.linux.dev" <llvm@lists.linux.dev> Subject: Re: [PATCH v5] coresight: etm4x: avoid build failure with unrolled loops Date: Fri, 8 Jul 2022 16:04:10 -0700 [thread overview] Message-ID: <CAKwvOd=kcROA30fmviABhfUiDX2v8QYLPPmUV0hnQ2A29tMtDQ@mail.gmail.com> (raw) In-Reply-To: <bd4a9bad394b478f9ee0d9c0981948f8@AcuMS.aculab.com> On Tue, Jun 28, 2022 at 2:40 AM David Laight <David.Laight@aculab.com> wrote: > > ... > > > Regardless of which compiler or compiler options determine whether a > > > loop can or can't be unrolled, which determines whether > > > __builtin_constant_p evaluates to true when passed an expression using a > > > loop induction variable, it is NEVER safe to allow the preprocessor to > > > construct inline asm like: > > > asm volatile (".inst (0x160 + (i * 4))" : "=r"(__val)); > > > ^ expected constant expression > > Can't you use (IIRC) an "=i" constraint with the C expression > so that the compiler evaluates the expression and passes the > correct constant value to the assembler? Yes, though I think it may be even simpler for me to just use __is_constexpr from include/linux/const.h here than try to rewrite the existing macro soup to avoid calls to read_sysreg_s. Will send a follow up. diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index 33869c1d20c3..a7bfea31f7d8 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -7,6 +7,7 @@ #define _CORESIGHT_CORESIGHT_ETM_H #include <asm/local.h> +#include <linux/const.h> #include <linux/spinlock.h> #include <linux/types.h> #include "coresight-priv.h" @@ -515,7 +516,7 @@ ({ \ u64 __val; \ \ - if (__builtin_constant_p((offset))) \ + if (__is_constexpr((offset))) \ __val = read_etm4x_sysreg_const_offset((offset)); \ else \ __val = etm4x_sysreg_read((offset), true, (_64bit)); \ -- Thanks, ~Nick Desaulniers
WARNING: multiple messages have this Message-ID (diff)
From: Nick Desaulniers <ndesaulniers@google.com> To: David Laight <David.Laight@aculab.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>, Mathieu Poirier <mathieu.poirier@linaro.org>, Arnd Bergmann <arnd@kernel.org>, Tao Zhang <quic_taozha@quicinc.com>, Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linaro.org>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Nathan Chancellor <nathan@kernel.org>, Tom Rix <trix@redhat.com>, "coresight@lists.linaro.org" <coresight@lists.linaro.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "llvm@lists.linux.dev" <llvm@lists.linux.dev> Subject: Re: [PATCH v5] coresight: etm4x: avoid build failure with unrolled loops Date: Fri, 8 Jul 2022 16:04:10 -0700 [thread overview] Message-ID: <CAKwvOd=kcROA30fmviABhfUiDX2v8QYLPPmUV0hnQ2A29tMtDQ@mail.gmail.com> (raw) In-Reply-To: <bd4a9bad394b478f9ee0d9c0981948f8@AcuMS.aculab.com> On Tue, Jun 28, 2022 at 2:40 AM David Laight <David.Laight@aculab.com> wrote: > > ... > > > Regardless of which compiler or compiler options determine whether a > > > loop can or can't be unrolled, which determines whether > > > __builtin_constant_p evaluates to true when passed an expression using a > > > loop induction variable, it is NEVER safe to allow the preprocessor to > > > construct inline asm like: > > > asm volatile (".inst (0x160 + (i * 4))" : "=r"(__val)); > > > ^ expected constant expression > > Can't you use (IIRC) an "=i" constraint with the C expression > so that the compiler evaluates the expression and passes the > correct constant value to the assembler? Yes, though I think it may be even simpler for me to just use __is_constexpr from include/linux/const.h here than try to rewrite the existing macro soup to avoid calls to read_sysreg_s. Will send a follow up. diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index 33869c1d20c3..a7bfea31f7d8 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -7,6 +7,7 @@ #define _CORESIGHT_CORESIGHT_ETM_H #include <asm/local.h> +#include <linux/const.h> #include <linux/spinlock.h> #include <linux/types.h> #include "coresight-priv.h" @@ -515,7 +516,7 @@ ({ \ u64 __val; \ \ - if (__builtin_constant_p((offset))) \ + if (__is_constexpr((offset))) \ __val = read_etm4x_sysreg_const_offset((offset)); \ else \ __val = etm4x_sysreg_read((offset), true, (_64bit)); \ -- Thanks, ~Nick Desaulniers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-07-08 23:04 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-14 22:02 [PATCH v4] coresight: etm4x: avoid build failure with unrolled loops Nick Desaulniers 2022-06-14 22:02 ` Nick Desaulniers 2022-06-23 9:46 ` Suzuki K Poulose 2022-06-23 9:46 ` Suzuki K Poulose 2022-06-23 17:41 ` [PATCH v5] " Nick Desaulniers 2022-06-23 17:41 ` Nick Desaulniers 2022-06-27 21:44 ` Suzuki K Poulose 2022-06-27 21:44 ` Suzuki K Poulose 2022-06-28 9:40 ` David Laight 2022-06-28 9:40 ` David Laight 2022-07-08 23:04 ` Nick Desaulniers [this message] 2022-07-08 23:04 ` Nick Desaulniers
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAKwvOd=kcROA30fmviABhfUiDX2v8QYLPPmUV0hnQ2A29tMtDQ@mail.gmail.com' \ --to=ndesaulniers@google.com \ --cc=David.Laight@aculab.com \ --cc=alexander.shishkin@linux.intel.com \ --cc=arnd@kernel.org \ --cc=coresight@lists.linaro.org \ --cc=leo.yan@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=llvm@lists.linux.dev \ --cc=mathieu.poirier@linaro.org \ --cc=mike.leach@linaro.org \ --cc=nathan@kernel.org \ --cc=quic_taozha@quicinc.com \ --cc=suzuki.poulose@arm.com \ --cc=trix@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.