public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] scsi: ufs: Fix the build for gcc 9 and before
@ 2023-08-01 23:21 Bart Van Assche
  2023-08-02  6:47 ` Arnd Bergmann
  2023-08-08  1:12 ` Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: Bart Van Assche @ 2023-08-01 23:21 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Arnd Bergmann, Naresh Kamboju,
	Nathan Chancellor, 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>
Cc: Nathan Chancellor <nathan@kernel.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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 23335aaa6a66..4f5174735a4c 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -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);
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: ufs: Fix the build for gcc 9 and before
  2023-08-01 23:21 [PATCH v2] scsi: ufs: Fix the build for gcc 9 and before Bart Van Assche
@ 2023-08-02  6:47 ` Arnd Bergmann
  2023-08-02  7:22   ` Naresh Kamboju
  2023-08-08  1:12 ` Martin K. Petersen
  1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2023-08-02  6:47 UTC (permalink / raw)
  To: Bart Van Assche, Martin K. Petersen
  Cc: linux-scsi, Naresh Kamboju, Nathan Chancellor,
	James E.J. Bottomley, Stanley Chu, Avri Altman, Bean Huo,
	Asutosh Das, Bao D. Nguyen, Arthur Simchaev, Can Guo

On Wed, Aug 2, 2023, at 01:21, 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>
> Cc: Nathan Chancellor <nathan@kernel.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>

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 <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: ufs: Fix the build for gcc 9 and before
  2023-08-02  6:47 ` Arnd Bergmann
@ 2023-08-02  7:22   ` Naresh Kamboju
  0 siblings, 0 replies; 4+ messages in thread
From: Naresh Kamboju @ 2023-08-02  7:22 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K. Petersen, linux-scsi, Nathan Chancellor,
	James E.J. Bottomley, Stanley Chu, Avri Altman, Bean Huo,
	Asutosh Das, Bao D. Nguyen, Arthur Simchaev, Can Guo,
	Arnd Bergmann

On Wed, 2 Aug 2023 at 12:18, Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Wed, Aug 2, 2023, at 01:21, 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>
> > Cc: Nathan Chancellor <nathan@kernel.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>

Would it be a good idea to provide a link to the original report ?
Link: https://lore.kernel.org/linux-scsi/CA+G9fYur8UJoUyTLJFVEJPh-15TJ7kbdD2q8xVz8a3fLjkxxVw@mail.gmail.com/

>
> 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 <arnd@arndb.de>

--
Linaro LKFT
https://lkft.linaro.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: ufs: Fix the build for gcc 9 and before
  2023-08-01 23:21 [PATCH v2] scsi: ufs: Fix the build for gcc 9 and before Bart Van Assche
  2023-08-02  6:47 ` Arnd Bergmann
@ 2023-08-08  1:12 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-08-08  1:12 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, linux-scsi, Arnd Bergmann, Naresh Kamboju,
	Nathan Chancellor, James E.J. Bottomley, Stanley Chu, Avri Altman,
	Bean Huo, Asutosh Das, Bao D. Nguyen, Arthur Simchaev, Can Guo


Bart,

> 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!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-08  1:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-01 23:21 [PATCH v2] scsi: ufs: Fix the build for gcc 9 and before Bart Van Assche
2023-08-02  6:47 ` Arnd Bergmann
2023-08-02  7:22   ` Naresh Kamboju
2023-08-08  1:12 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox