* drivers/net/can/spi/mcp251xfd/mcp251xfd.h:481:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to ... @ 2022-05-18 6:45 kernel test robot 2022-05-18 7:05 ` Marc Kleine-Budde 0 siblings, 1 reply; 8+ messages in thread From: kernel test robot @ 2022-05-18 6:45 UTC (permalink / raw) To: Marc Kleine-Budde; +Cc: llvm, kbuild-all, linux-kernel tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 210e04ff768142b96452030c4c2627512b30ad95 commit: eb79a267c9b3e608e7762a1b221428f37ace3aa3 can: mcp251xfd: rename all remaining occurrence to mcp251xfd date: 1 year, 8 months ago config: arm-randconfig-c002-20220518 (https://download.01.org/0day-ci/archive/20220518/202205181414.n8QRDe8k-lkp@intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 853fa8ee225edf2d0de94b0dcbd31bea916e825e) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm cross compiling tool for clang build # apt-get install binutils-arm-linux-gnueabi # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eb79a267c9b3e608e7762a1b221428f37ace3aa3 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout eb79a267c9b3e608e7762a1b221428f37ace3aa3 # save the config file COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/net/can/spi/mcp251xfd/mcp251xfd.h:481:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access] struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; ^ drivers/net/can/spi/mcp251xfd/mcp251xfd.h:485:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:483:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:483:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access] struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; ^ drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:511:1: warning: unused function 'mcp251xfd_chip_set_mode_nowait' [-Wunused-function] mcp251xfd_chip_set_mode_nowait(const struct mcp251xfd_priv *priv, ^ 3 warnings generated. -- >> drivers/net/can/spi/mcp251xfd/mcp251xfd.h:481:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access] struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; ^ drivers/net/can/spi/mcp251xfd/mcp251xfd.h:485:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:483:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:483:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access] struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; ^ 2 warnings generated. vim +481 drivers/net/can/spi/mcp251xfd/mcp251xfd.h 477 478 union mcp251xfd_tx_obj_load_buf { 479 struct __packed { 480 struct mcp251xfd_buf_cmd cmd; > 481 struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; 482 } nocrc; 483 struct __packed { 484 struct mcp251xfd_buf_cmd_crc cmd; 485 struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; 486 __be16 crc; 487 } crc; 488 } ____cacheline_aligned; 489 -- 0-DAY CI Kernel Test Service https://01.org/lkp ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: drivers/net/can/spi/mcp251xfd/mcp251xfd.h:481:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to ... 2022-05-18 6:45 drivers/net/can/spi/mcp251xfd/mcp251xfd.h:481:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to kernel test robot @ 2022-05-18 7:05 ` Marc Kleine-Budde 2022-05-18 11:43 ` [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning Vincent Mailhol 0 siblings, 1 reply; 8+ messages in thread From: Marc Kleine-Budde @ 2022-05-18 7:05 UTC (permalink / raw) To: kernel test robot; +Cc: llvm, kbuild-all, linux-kernel, linux-can [-- Attachment #1: Type: text/plain, Size: 4977 bytes --] On 18.05.2022 14:45:33, kernel test robot wrote: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > head: 210e04ff768142b96452030c4c2627512b30ad95 > commit: eb79a267c9b3e608e7762a1b221428f37ace3aa3 can: mcp251xfd: rename all remaining occurrence to mcp251xfd > date: 1 year, 8 months ago > config: arm-randconfig-c002-20220518 (https://download.01.org/0day-ci/archive/20220518/202205181414.n8QRDe8k-lkp@intel.com/config) > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 853fa8ee225edf2d0de94b0dcbd31bea916e825e) > reproduce (this is a W=1 build): > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # install arm cross compiling tool for clang build > # apt-get install binutils-arm-linux-gnueabi > # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eb79a267c9b3e608e7762a1b221428f37ace3aa3 > git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > git fetch --no-tags linus master > git checkout eb79a267c9b3e608e7762a1b221428f37ace3aa3 > # save the config file > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot <lkp@intel.com> > > All warnings (new ones prefixed by >>): > > >> drivers/net/can/spi/mcp251xfd/mcp251xfd.h:481:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access] > struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > ^ > drivers/net/can/spi/mcp251xfd/mcp251xfd.h:485:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:483:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:483:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access] > struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > ^ > drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:511:1: warning: unused function 'mcp251xfd_chip_set_mode_nowait' [-Wunused-function] > mcp251xfd_chip_set_mode_nowait(const struct mcp251xfd_priv *priv, > ^ > 3 warnings generated. > -- > >> drivers/net/can/spi/mcp251xfd/mcp251xfd.h:481:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access] > struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > ^ > drivers/net/can/spi/mcp251xfd/mcp251xfd.h:485:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:483:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:483:2)' being packed, which can lead to unaligned accesses [-Wunaligned-access] > struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > ^ > 2 warnings generated. > > > vim +481 drivers/net/can/spi/mcp251xfd/mcp251xfd.h > > 477 > 478 union mcp251xfd_tx_obj_load_buf { > 479 struct __packed { > 480 struct mcp251xfd_buf_cmd cmd; > > 481 struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > 482 } nocrc; > 483 struct __packed { > 484 struct mcp251xfd_buf_cmd_crc cmd; > 485 struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > 486 __be16 crc; > 487 } crc; > 488 } ____cacheline_aligned; > 489 The structure layout is intentional as it describes the hardware messages on the SPI bus. The functions accessing these structs use appropriate put_unaligned_*() functions. How to properly annotate these structs to silence the warnings? Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning 2022-05-18 7:05 ` Marc Kleine-Budde @ 2022-05-18 11:43 ` Vincent Mailhol 2022-05-18 11:58 ` Marc Kleine-Budde 2022-05-18 16:05 ` Nathan Chancellor 0 siblings, 2 replies; 8+ messages in thread From: Vincent Mailhol @ 2022-05-18 11:43 UTC (permalink / raw) To: Marc Kleine-Budde, kernel test robot Cc: llvm, kbuild-all, linux-kernel, linux-can, Vincent Mailhol clang emits a -Wunaligned-access warning on union mcp251xfd_tx_ojb_load_buf. The reason is that field hw_tx_obj (not declared as packed) is being packed right after a 16 bits field inside a packed struct: | union mcp251xfd_tx_obj_load_buf { | struct __packed { | struct mcp251xfd_buf_cmd cmd; | /* ^ 16 bits fields */ | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; | /* ^ not declared as packed */ | } nocrc; | struct __packed { | struct mcp251xfd_buf_cmd_crc cmd; | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; | __be16 crc; | } crc; | } ____cacheline_aligned; Starting from LLVM 14, having an unpacked struct nested in a packed struct triggers a warning. c.f. [1]. This is a false positive because the field is always being accessed with the relevant put_unaligned_*() function. Adding __packed to the structure declaration silences the warning. [1] https://github.com/llvm/llvm-project/issues/55520 Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> --- Actually, I do not have llvm 14 installed so I am not able to test (this check was introduced in v14). But as explained in [1], adding __packed should fix the warning. Because this is a false positive, I did not add a Fixes tag, nor a Reported-by: kernel test robot. --- drivers/net/can/spi/mcp251xfd/mcp251xfd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd.h b/drivers/net/can/spi/mcp251xfd/mcp251xfd.h index 1d43bccc29bf..2b0309fedfac 100644 --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd.h +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd.h @@ -441,7 +441,7 @@ struct mcp251xfd_hw_tef_obj { /* The tx_obj_raw version is used in spi async, i.e. without * regmap. We have to take care of endianness ourselves. */ -struct mcp251xfd_hw_tx_obj_raw { +struct __packed mcp251xfd_hw_tx_obj_raw { __le32 id; __le32 flags; u8 data[sizeof_field(struct canfd_frame, data)]; -- 2.35.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning 2022-05-18 11:43 ` [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning Vincent Mailhol @ 2022-05-18 11:58 ` Marc Kleine-Budde 2022-05-18 16:05 ` Nathan Chancellor 1 sibling, 0 replies; 8+ messages in thread From: Marc Kleine-Budde @ 2022-05-18 11:58 UTC (permalink / raw) To: Vincent Mailhol Cc: kernel test robot, llvm, kbuild-all, linux-kernel, linux-can [-- Attachment #1: Type: text/plain, Size: 1456 bytes --] On 18.05.2022 20:43:57, Vincent Mailhol wrote: > clang emits a -Wunaligned-access warning on union > mcp251xfd_tx_ojb_load_buf. > > The reason is that field hw_tx_obj (not declared as packed) is being > packed right after a 16 bits field inside a packed struct: > > | union mcp251xfd_tx_obj_load_buf { > | struct __packed { > | struct mcp251xfd_buf_cmd cmd; > | /* ^ 16 bits fields */ > | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > | /* ^ not declared as packed */ > | } nocrc; > | struct __packed { > | struct mcp251xfd_buf_cmd_crc cmd; > | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > | __be16 crc; > | } crc; > | } ____cacheline_aligned; > > Starting from LLVM 14, having an unpacked struct nested in a packed > struct triggers a warning. c.f. [1]. > > This is a false positive because the field is always being accessed > with the relevant put_unaligned_*() function. Adding __packed to the > structure declaration silences the warning. > > [1] https://github.com/llvm/llvm-project/issues/55520 > > Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Thank! Applies to linux-can-next/testing. regards, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning 2022-05-18 11:43 ` [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning Vincent Mailhol 2022-05-18 11:58 ` Marc Kleine-Budde @ 2022-05-18 16:05 ` Nathan Chancellor 2022-05-18 16:15 ` Vincent MAILHOL 1 sibling, 1 reply; 8+ messages in thread From: Nathan Chancellor @ 2022-05-18 16:05 UTC (permalink / raw) To: Vincent Mailhol Cc: Marc Kleine-Budde, kernel test robot, llvm, kbuild-all, linux-kernel, linux-can Hi Vincent, On Wed, May 18, 2022 at 08:43:57PM +0900, Vincent Mailhol wrote: > clang emits a -Wunaligned-access warning on union > mcp251xfd_tx_ojb_load_buf. > > The reason is that field hw_tx_obj (not declared as packed) is being > packed right after a 16 bits field inside a packed struct: > > | union mcp251xfd_tx_obj_load_buf { > | struct __packed { > | struct mcp251xfd_buf_cmd cmd; > | /* ^ 16 bits fields */ > | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > | /* ^ not declared as packed */ > | } nocrc; > | struct __packed { > | struct mcp251xfd_buf_cmd_crc cmd; > | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > | __be16 crc; > | } crc; > | } ____cacheline_aligned; > > Starting from LLVM 14, having an unpacked struct nested in a packed > struct triggers a warning. c.f. [1]. > > This is a false positive because the field is always being accessed > with the relevant put_unaligned_*() function. Adding __packed to the > structure declaration silences the warning. > > [1] https://github.com/llvm/llvm-project/issues/55520 > > Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> > --- > Actually, I do not have llvm 14 installed so I am not able to test > (this check was introduced in v14). But as explained in [1], adding > __packed should fix the warning. Thanks for the patch! This does resolve the warning (verified with LLVM 15). > Because this is a false positive, I did not add a Fixes tag, nor a > Reported-by: kernel test robot. I think that the Reported-by tag should always be included but I agree that a Fixes tag is not necessary for this warning, as we currently have it under W=1, so it should not be visible under normal circumstances. > --- > drivers/net/can/spi/mcp251xfd/mcp251xfd.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd.h b/drivers/net/can/spi/mcp251xfd/mcp251xfd.h > index 1d43bccc29bf..2b0309fedfac 100644 > --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd.h > +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd.h > @@ -441,7 +441,7 @@ struct mcp251xfd_hw_tef_obj { > /* The tx_obj_raw version is used in spi async, i.e. without > * regmap. We have to take care of endianness ourselves. > */ > -struct mcp251xfd_hw_tx_obj_raw { > +struct __packed mcp251xfd_hw_tx_obj_raw { > __le32 id; > __le32 flags; > u8 data[sizeof_field(struct canfd_frame, data)]; > -- > 2.35.1 > > Cheers, Nathan ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning 2022-05-18 16:05 ` Nathan Chancellor @ 2022-05-18 16:15 ` Vincent MAILHOL 2022-05-18 16:18 ` Nathan Chancellor 0 siblings, 1 reply; 8+ messages in thread From: Vincent MAILHOL @ 2022-05-18 16:15 UTC (permalink / raw) To: Nathan Chancellor Cc: Marc Kleine-Budde, kernel test robot, llvm, kbuild-all, linux-kernel, linux-can On Tue. 19 May 2022 at 01:08, Nathan Chancellor <nathan@kernel.org> wrote: > Hi Vincent, > > On Wed, May 18, 2022 at 08:43:57PM +0900, Vincent Mailhol wrote: > > clang emits a -Wunaligned-access warning on union > > mcp251xfd_tx_ojb_load_buf. > > > > The reason is that field hw_tx_obj (not declared as packed) is being > > packed right after a 16 bits field inside a packed struct: > > > > | union mcp251xfd_tx_obj_load_buf { > > | struct __packed { > > | struct mcp251xfd_buf_cmd cmd; > > | /* ^ 16 bits fields */ > > | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > > | /* ^ not declared as packed */ > > | } nocrc; > > | struct __packed { > > | struct mcp251xfd_buf_cmd_crc cmd; > > | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > > | __be16 crc; > > | } crc; > > | } ____cacheline_aligned; > > > > Starting from LLVM 14, having an unpacked struct nested in a packed > > struct triggers a warning. c.f. [1]. > > > > This is a false positive because the field is always being accessed > > with the relevant put_unaligned_*() function. Adding __packed to the > > structure declaration silences the warning. > > > > [1] https://github.com/llvm/llvm-project/issues/55520 > > > > Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> > > --- > > Actually, I do not have llvm 14 installed so I am not able to test > > (this check was introduced in v14). But as explained in [1], adding > > __packed should fix the warning. > > Thanks for the patch! This does resolve the warning (verified with LLVM > 15). Great, thanks for the check! Does this mean we can add you Tested-by (I assume yes, c.f. below, if not the case, please raise your voice). > > Because this is a false positive, I did not add a Fixes tag, nor a > > Reported-by: kernel test robot. > > I think that the Reported-by tag should always be included but I agree > that a Fixes tag is not necessary for this warning, as we currently have > it under W=1, so it should not be visible under normal circumstances. ACK. Marc, can you directly add below tags to the patch: Reported-by: kernel test robot <lkp@intel.com> Tested-by: Nathan Chancellor <nathan@kernel.org> Or do you want me to send a v2? Yours sincerely, Vincent Mailhol ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning 2022-05-18 16:15 ` Vincent MAILHOL @ 2022-05-18 16:18 ` Nathan Chancellor 2022-05-18 20:15 ` Marc Kleine-Budde 0 siblings, 1 reply; 8+ messages in thread From: Nathan Chancellor @ 2022-05-18 16:18 UTC (permalink / raw) To: Vincent MAILHOL Cc: Marc Kleine-Budde, kernel test robot, llvm, kbuild-all, linux-kernel, linux-can On Thu, May 19, 2022 at 01:15:04AM +0900, Vincent MAILHOL wrote: > On Tue. 19 May 2022 at 01:08, Nathan Chancellor <nathan@kernel.org> wrote: > > Hi Vincent, > > > > On Wed, May 18, 2022 at 08:43:57PM +0900, Vincent Mailhol wrote: > > > clang emits a -Wunaligned-access warning on union > > > mcp251xfd_tx_ojb_load_buf. > > > > > > The reason is that field hw_tx_obj (not declared as packed) is being > > > packed right after a 16 bits field inside a packed struct: > > > > > > | union mcp251xfd_tx_obj_load_buf { > > > | struct __packed { > > > | struct mcp251xfd_buf_cmd cmd; > > > | /* ^ 16 bits fields */ > > > | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > > > | /* ^ not declared as packed */ > > > | } nocrc; > > > | struct __packed { > > > | struct mcp251xfd_buf_cmd_crc cmd; > > > | struct mcp251xfd_hw_tx_obj_raw hw_tx_obj; > > > | __be16 crc; > > > | } crc; > > > | } ____cacheline_aligned; > > > > > > Starting from LLVM 14, having an unpacked struct nested in a packed > > > struct triggers a warning. c.f. [1]. > > > > > > This is a false positive because the field is always being accessed > > > with the relevant put_unaligned_*() function. Adding __packed to the > > > structure declaration silences the warning. > > > > > > [1] https://github.com/llvm/llvm-project/issues/55520 > > > > > > Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> > > > --- > > > Actually, I do not have llvm 14 installed so I am not able to test > > > (this check was introduced in v14). But as explained in [1], adding > > > __packed should fix the warning. > > > > Thanks for the patch! This does resolve the warning (verified with LLVM > > 15). > > Great, thanks for the check! Does this mean we can add you Tested-by > (I assume yes, c.f. below, if not the case, please raise your voice). Sure, see below. > > > Because this is a false positive, I did not add a Fixes tag, nor a > > > Reported-by: kernel test robot. > > > > I think that the Reported-by tag should always be included but I agree > > that a Fixes tag is not necessary for this warning, as we currently have > > it under W=1, so it should not be visible under normal circumstances. > > ACK. > Marc, can you directly add below tags to the patch: > > Reported-by: kernel test robot <lkp@intel.com> > Tested-by: Nathan Chancellor <nathan@kernel.org> Please use: Tested-by: Nathan Chancellor <nathan@kernel.org> # build To make it clear that I didn't perform anything more than a build test to see that the warning is fixed. Cheers, Nathan ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning 2022-05-18 16:18 ` Nathan Chancellor @ 2022-05-18 20:15 ` Marc Kleine-Budde 0 siblings, 0 replies; 8+ messages in thread From: Marc Kleine-Budde @ 2022-05-18 20:15 UTC (permalink / raw) To: Nathan Chancellor Cc: Vincent MAILHOL, kernel test robot, llvm, kbuild-all, linux-kernel, linux-can [-- Attachment #1: Type: text/plain, Size: 1106 bytes --] On 18.05.2022 09:18:19, Nathan Chancellor wrote: > > > > Because this is a false positive, I did not add a Fixes tag, nor a > > > > Reported-by: kernel test robot. > > > > > > I think that the Reported-by tag should always be included but I agree > > > that a Fixes tag is not necessary for this warning, as we currently have > > > it under W=1, so it should not be visible under normal circumstances. > > > > ACK. > > Marc, can you directly add below tags to the patch: > > > > Reported-by: kernel test robot <lkp@intel.com> > > Tested-by: Nathan Chancellor <nathan@kernel.org> > > Please use: > > Tested-by: Nathan Chancellor <nathan@kernel.org> # build > > To make it clear that I didn't perform anything more than a build test > to see that the warning is fixed. I've updated the tags! Thanks, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-05-18 20:15 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-05-18 6:45 drivers/net/can/spi/mcp251xfd/mcp251xfd.h:481:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to kernel test robot 2022-05-18 7:05 ` Marc Kleine-Budde 2022-05-18 11:43 ` [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning Vincent Mailhol 2022-05-18 11:58 ` Marc Kleine-Budde 2022-05-18 16:05 ` Nathan Chancellor 2022-05-18 16:15 ` Vincent MAILHOL 2022-05-18 16:18 ` Nathan Chancellor 2022-05-18 20:15 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).