scsi: ufs: Fix the build for gcc 9 and before
Subsystems (2)
Bart Van Assche
reviewerPATCH v2 1/1 scsi: ufs: Fix the build for gcc 9 and before
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.
--- drivers/ufs/core/ufshcd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/ufs/core/ufshcd.c +8 -0
@@ -10564,6 +10564,14 @@ static const struct dev_pm_ops ufshcd_wl_pm_ops = {static void ufshcd_check_header_layout (void ) { +/* +* gcc compilers before version 10 cannot do constant-folding for +* sub-byte bitfields. Hence skip the layout checks for gcc 9 and +* before. +*/ +if (IS_ENABLED (CONFIG_CC_IS_GCC ) &&CONFIG_GCC_VERSION <100000 ) +return ; +BUILD_BUG_ON (((u8 *)&(struct request_desc_header ){ .cci =3 })[0 ] !=3 );
Quoted 10 lines · Bart Van Assche
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 <[email protected]>Cc Naresh Kamboju <[email protected]>Cc Nathan Chancellor <[email protected]>Reported-by Naresh Kamboju <[email protected]>Suggested-by Arnd Bergmann <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Looks good to me, I gave it a quick spin with all versions from gcc-6 through gcc-10 to make sure this works for all of them.
Quoted 6 lines · Arnd Bergmann
Quoted 4 lines · Bart Van Assche
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.
Quoted 6 lines
Quoted 6 lines
Cc Arnd Bergmann <[email protected]>Cc Naresh Kamboju <[email protected]>Cc Nathan Chancellor <[email protected]>Reported-by Naresh Kamboju <[email protected]>Suggested-by Arnd Bergmann <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Would it be a good idea to provide a link to the original report ?
Quoted 6 lines
Looks good to me, I gave it a quick spin with all versions from gcc-6 through gcc-10 to make sure this works for all of them.
Tested-by Arnd Bergmann <[email protected]>
--
Linaro LKFT
https://lkft.linaro.org
Martin K. Petersen
AppliedBart,
Quoted 3 lines
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.
Applied to 6.6/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering