diff mbox series

[v3] drm/amd/amdgpu: Properly tune the size of struct

Message ID 3BC6F04B763EF430+20240731041040.43863-1-wangyuli@uniontech.com (mailing list archive)
State New, archived
Headers show
Series [v3] drm/amd/amdgpu: Properly tune the size of struct | expand

Commit Message

WangYuli July 31, 2024, 4:10 a.m. UTC
The struct assertion is failed because sparse cannot parse
`#pragma pack(push, 1)` and `#pragma pack(pop)` correctly.
GCC's output is still 1-byte-aligned. No harm to memory layout.

The error can be filtered out by sparse-diff, but sometimes
multiple lines queezed into one, making the sparse-diff thinks
its a new error. I'm trying to aviod this by fixing errors.

Link: https://lore.kernel.org/all/20230620045919.492128-1-suhui@nfschina.com/
Link: https://lore.kernel.org/all/93d10611-9fbb-4242-87b8-5860b2606042@suswa.mountain/
Fixes: 1721bc1b2afa ("drm/amdgpu: Update VF2PF interface")
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Cc: wenlunpeng <wenlunpeng@uniontech.com>
Reported-by: Su Hui <suhui@nfschina.com>
Signed-off-by: WangYuli <wangyuli@uniontech.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alex Deucher Aug. 5, 2024, 7:49 p.m. UTC | #1
Applied.  Thanks!

On Wed, Jul 31, 2024 at 6:25 AM WangYuli <wangyuli@uniontech.com> wrote:
>
> The struct assertion is failed because sparse cannot parse
> `#pragma pack(push, 1)` and `#pragma pack(pop)` correctly.
> GCC's output is still 1-byte-aligned. No harm to memory layout.
>
> The error can be filtered out by sparse-diff, but sometimes
> multiple lines queezed into one, making the sparse-diff thinks
> its a new error. I'm trying to aviod this by fixing errors.
>
> Link: https://lore.kernel.org/all/20230620045919.492128-1-suhui@nfschina.com/
> Link: https://lore.kernel.org/all/93d10611-9fbb-4242-87b8-5860b2606042@suswa.mountain/
> Fixes: 1721bc1b2afa ("drm/amdgpu: Update VF2PF interface")
> Cc: Dan Carpenter <dan.carpenter@linaro.org>
> Cc: wenlunpeng <wenlunpeng@uniontech.com>
> Reported-by: Su Hui <suhui@nfschina.com>
> Signed-off-by: WangYuli <wangyuli@uniontech.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
> index fb2b394bb9c5..6e9eeaeb3de1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
> @@ -213,7 +213,7 @@ struct amd_sriov_msg_pf2vf_info {
>         uint32_t gpu_capacity;
>         /* reserved */
>         uint32_t reserved[256 - AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE];
> -};
> +} __packed;
>
>  struct amd_sriov_msg_vf2pf_info_header {
>         /* the total structure size in byte */
> @@ -273,7 +273,7 @@ struct amd_sriov_msg_vf2pf_info {
>         uint32_t mes_info_size;
>         /* reserved */
>         uint32_t reserved[256 - AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE];
> -};
> +} __packed;
>
>  /* mailbox message send from guest to host  */
>  enum amd_sriov_mailbox_request_message {
> --
> 2.43.4
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
index fb2b394bb9c5..6e9eeaeb3de1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
@@ -213,7 +213,7 @@  struct amd_sriov_msg_pf2vf_info {
 	uint32_t gpu_capacity;
 	/* reserved */
 	uint32_t reserved[256 - AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE];
-};
+} __packed;
 
 struct amd_sriov_msg_vf2pf_info_header {
 	/* the total structure size in byte */
@@ -273,7 +273,7 @@  struct amd_sriov_msg_vf2pf_info {
 	uint32_t mes_info_size;
 	/* reserved */
 	uint32_t reserved[256 - AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE];
-};
+} __packed;
 
 /* mailbox message send from guest to host  */
 enum amd_sriov_mailbox_request_message {