* [PATCH] scsi: ufs: Fix the build for gcc 9 and before
@ 2023-08-01 20:13 Bart Van Assche
2023-08-01 21:52 ` Nathan Chancellor
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2023-08-01 20:13 UTC (permalink / raw)
To: Martin K . Petersen
Cc: linux-scsi, Bart Van Assche, Arnd Bergmann, Naresh Kamboju,
James E.J. Bottomley, Stanley Chu, Avri Altman, Bean Huo,
Asutosh Das, Bao D. Nguyen, Arthur Simchaev, Can Guo
gcc compilers before version 10 cannot do constant-folding for sub-byte
bitfields. This makes the compiler layout tests fail. Hence skip the
layout checks for gcc 9 and before.
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/ufshcd.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 23335aaa6a66..875c860bcc05 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10564,6 +10564,15 @@ static const struct dev_pm_ops ufshcd_wl_pm_ops = {
static void ufshcd_check_header_layout(void)
{
+#if defined(__GNUC__) && __GNUC__ -0 < 10
+ /*
+ * gcc compilers before version 10 cannot do constant-folding for
+ * sub-byte bitfields. Hence skip the layout checks for gcc 9 and
+ * before.
+ */
+ return;
+#endif
+
BUILD_BUG_ON(((u8 *)&(struct request_desc_header){
.cci = 3})[0] != 3);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: ufs: Fix the build for gcc 9 and before
2023-08-01 20:13 [PATCH] scsi: ufs: Fix the build for gcc 9 and before Bart Van Assche
@ 2023-08-01 21:52 ` Nathan Chancellor
2023-08-01 23:23 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2023-08-01 21:52 UTC (permalink / raw)
To: Bart Van Assche
Cc: Martin K . Petersen, linux-scsi, Arnd Bergmann, Naresh Kamboju,
James E.J. Bottomley, Stanley Chu, Avri Altman, Bean Huo,
Asutosh Das, Bao D. Nguyen, Arthur Simchaev, Can Guo, llvm
On Tue, Aug 01, 2023 at 01:13:23PM -0700, Bart Van Assche wrote:
> gcc compilers before version 10 cannot do constant-folding for sub-byte
> bitfields. This makes the compiler layout tests fail. Hence skip the
> layout checks for gcc 9 and before.
>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/ufs/core/ufshcd.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 23335aaa6a66..875c860bcc05 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -10564,6 +10564,15 @@ static const struct dev_pm_ops ufshcd_wl_pm_ops = {
>
> static void ufshcd_check_header_layout(void)
> {
> +#if defined(__GNUC__) && __GNUC__ -0 < 10
clang defines __GNUC__ and it does not sound like it is impacted by this
issue? I just built with LLVM 11 through 17 and did not see it. Can this
be made more specific?
Also, can we use IS_ENABLED() and not rely on the preprocessor? This
appears to work for me.
if (IS_ENABLED(CONFIG_CC_IS_GCC) && CONFIG_GCC_VERSION < 100000)
return;
> + /*
> + * gcc compilers before version 10 cannot do constant-folding for
> + * sub-byte bitfields. Hence skip the layout checks for gcc 9 and
> + * before.
> + */
> + return;
> +#endif
> +
> BUILD_BUG_ON(((u8 *)&(struct request_desc_header){
> .cci = 3})[0] != 3);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: ufs: Fix the build for gcc 9 and before
2023-08-01 21:52 ` Nathan Chancellor
@ 2023-08-01 23:23 ` Bart Van Assche
0 siblings, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2023-08-01 23:23 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Martin K . Petersen, linux-scsi, Arnd Bergmann, Naresh Kamboju,
James E.J. Bottomley, Stanley Chu, Avri Altman, Bean Huo,
Asutosh Das, Bao D. Nguyen, Arthur Simchaev, Can Guo, llvm
On 8/1/23 14:52, Nathan Chancellor wrote:
> On Tue, Aug 01, 2023 at 01:13:23PM -0700, Bart Van Assche wrote:
>> static void ufshcd_check_header_layout(void)
>> {
>> +#if defined(__GNUC__) && __GNUC__ -0 < 10
>
> clang defines __GNUC__ and it does not sound like it is impacted by this
> issue? I just built with LLVM 11 through 17 and did not see it. Can this
> be made more specific?
>
> Also, can we use IS_ENABLED() and not rely on the preprocessor? This
> appears to work for me.
>
> if (IS_ENABLED(CONFIG_CC_IS_GCC) && CONFIG_GCC_VERSION < 100000)
> return;
Thanks for the feedback. A new version of this patch has been posted.
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-01 23:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-01 20:13 [PATCH] scsi: ufs: Fix the build for gcc 9 and before Bart Van Assche
2023-08-01 21:52 ` Nathan Chancellor
2023-08-01 23:23 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox