RDMA/efa: Fix node guid compiler warning
Subsystems (2)
Michael Margolin
maintainerPATCH 1/1 RDMA/efa: Fix node guid compiler warning
The GUID is received in big-endian so align types accordingly to avoid compiler warnings.
--- drivers/infiniband/hw/efa/efa_com_cmd.c | 2 +- drivers/infiniband/hw/efa/efa_com_cmd.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/efa/efa_com_cmd.c +1 -1
@@ -465,7 +465,7 @@ int efa_com_get_device_attr(struct efa_com_dev *edev, result->db_bar = resp.u.device_attr.db_bar; result->max_rdma_size = resp.u.device_attr.max_rdma_size; result->device_caps = resp.u.device_attr.device_caps; - result->guid = resp.u.device_attr.guid; + result->guid = (__force __be64 )resp.u.device_attr.guid;if (result->admin_api_version <1 ) { ibdev_err_ratelimited(
drivers/infiniband/hw/efa/efa_com_cmd.h +1 -1
@@ -112,7 +112,7 @@ struct efa_com_get_device_attr_result {u8 addr[EFA_GID_SIZE ];u64 page_size_cap;u64 max_mr_pages; -u64 guid; +__be64 guid;u32 mtu;u32 fw_version;u32 admin_api_version;
Signature · 1 line
2.40.1
Jason Gunthorpe
maintainerQuoted 20 lines · Michael Margolin
The GUID is received in big-endian so align types accordingly to avoid compiler warnings.
Fixes 04e36fd27a2a ("RDMA/efa: Add support for node guid")Reported-by kernel test robot <[email protected]>Reviewed-by Yehuda Yitschak <[email protected]>Reviewed-by Yonatan Nachum <[email protected]>Signed-off-by Michael Margolin <[email protected]>--- drivers/infiniband/hw/efa/efa_com_cmd.c | 2 +- drivers/infiniband/hw/efa/efa_com_cmd.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/hw/efa/efa_com_cmd.c +0
-0
drivers/infiniband/hw/efa/efa_com_cmd.c int efa_com_get_device_attr(struct efa_com_dev *edev, · line 468
Quoted 5 lines
drivers/infiniband/hw/efa/efa_com_cmd.c +1
-1@@ -465,7 +465,7 @@ int efa_com_get_device_attr(struct efa_com_dev *edev, result->db_bar = resp.u.device_attr.db_bar; result->max_rdma_size = resp.u.device_attr.max_rdma_size; result->device_caps = resp.u.device_attr.device_caps; - result->guid = resp.u.device_attr.guid; + result->guid = (__force __be64 )resp.u.device_attr.guid;
That can't be right, use the proper conversion function, or the proper type..
Jason
Margolin, Michael
maintainerQuoted 33 lines · Jason Gunthorpe
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
Quoted 20 lines · Michael Margolin
The GUID is received in big-endian so align types accordingly to avoid compiler warnings.
Fixes 04e36fd27a2a ("RDMA/efa: Add support for node guid")Reported-by kernel test robot <[email protected]>Reviewed-by Yehuda Yitschak <[email protected]>Reviewed-by Yonatan Nachum <[email protected]>Signed-off-by Michael Margolin <[email protected]>--- drivers/infiniband/hw/efa/efa_com_cmd.c | 2 +- drivers/infiniband/hw/efa/efa_com_cmd.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/hw/efa/efa_com_cmd.c +0
-0drivers/infiniband/hw/efa/efa_com_cmd.c int efa_com_get_device_attr(struct efa_com_dev *edev, · line 468
Quoted 5 lines
drivers/infiniband/hw/efa/efa_com_cmd.c +1
-1@@ -465,7 +465,7 @@ int efa_com_get_device_attr(struct efa_com_dev *edev, result->db_bar = resp.u.device_attr.db_bar; result->max_rdma_size = resp.u.device_attr.max_rdma_size; result->device_caps = resp.u.device_attr.device_caps; - result->guid = resp.u.device_attr.guid; + result->guid = (__force __be64 )resp.u.device_attr.guid;That can't be right, use the proper conversion function, or the proper type..
Quoted 1 line
Jason
The current assumption in the driver is that data from the device arrives in a correct byte order for the CPU, while the guid field is in reversed order.
Would you suggest doing something like:
Review
Quoted 2 lines
(quoted diff) +1
-1- result->guid = resp.u.device_attr.guid; + result->guid = __cpu_to_be64(__swab64(resp.u.device_attr.guid));
Michael
Margolin, Michael
maintainerQuoted 37 lines · Michael
Quoted 34 lines · Jason Gunthorpe
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
Quoted 20 lines · Michael Margolin
The GUID is received in big-endian so align types accordingly to avoid compiler warnings.
Fixes 04e36fd27a2a ("RDMA/efa: Add support for node guid")Reported-by kernel test robot <[email protected]>Reviewed-by Yehuda Yitschak <[email protected]>Reviewed-by Yonatan Nachum <[email protected]>Signed-off-by Michael Margolin <[email protected]>---
drivers/infiniband/hw/efa/efa_com_cmd.c| 2 +-drivers/infiniband/hw/efa/efa_com_cmd.h| 2 +-2 files changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/hw/efa/efa_com_cmd.c +0
-0drivers/infiniband/hw/efa/efa_com_cmd.c int efa_com_get_device_attr(struct efa_com_dev · line 469
Quoted 6 lines
drivers/infiniband/hw/efa/efa_com_cmd.c +1
-1@@ -465,7 +465,7 @@ int efa_com_get_device_attr(struct efa_com_dev *edev, result->db_bar = resp.u.device_attr.db_bar; result->max_rdma_size = resp.u.device_attr.max_rdma_size; result->device_caps = resp.u.device_attr.device_caps; - result->guid = resp.u.device_attr.guid; + result->guid = (__force __be64)resp.u.device_attr.guid;That can't be right, use the proper conversion function, or the proper type..
Quoted 1 line
Jason
Quoted 9 lines
The current assumption in the driver is that data from the device arrives in a correct byte order for the CPU, while the guid field is in reversed order.
Would you suggest doing something like:
Quoted 2 lines
-
result->guid= resp.u.device_attr.guid;
+result->guid= __cpu_to_be64(__swab64(resp.u.device_attr.guid));Michael
Actually that's wrong, the device always sets guid in BE order so no swap is needed in the driver in any case.
Jason Gunthorpe
maintainerQuoted 2 lines · Michael
Actually that's wrong, the device always sets guid in BE order so no swap is needed in the driver in any case.
They you just mark it as _be64 in the struct and there is no reason for the __force ?
Jason
Margolin, Michael
maintainerQuoted 4 lines · Jason Gunthorpe
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
Quoted 8 lines
Quoted 2 lines · Michael
Actually that's wrong, the device always sets guid in BE order so no swap is needed in the driver in any case.
They you just mark it as
_be64in the struct and there is no reason for the__force?Jason
That's probably the most correct way but I prefer to avoid introducing kernel specific types in a shared interface file.
Michael
Jason Gunthorpe
maintainerQuoted 10 lines · Michael
Quoted 8 lines · Jason Gunthorpe
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
Quoted 2 lines · Michael
Actually that's wrong, the device always sets guid in BE order so no swap is needed in the driver in any case.
Quoted 7 lines
Quoted 4 lines
They you just mark it as
_be64in the struct and there is no reason for the__force?Jason
That's probably the most correct way but I prefer to avoid introducing kernel specific types in a shared interface file.
?
what is a "shared interface file" ?
That doesn't sound like a linux thing
Jason
Margolin, Michael
maintainerQuoted 20 lines · Jason Gunthorpe
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
Quoted 7 lines · Michael
Quoted 6 lines · Jason Gunthorpe
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
On Thu, Sep 26, 2024 at 04:25:19PM +0300, Margolin, Michael wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Actually that's wrong, the device always sets guid in BE order so no swap is needed in the driver in any case.
They you just mark it as
_be64in the struct and there is no reason for the__force?Jason
That's probably the most correct way but I prefer to avoid introducing kernel specific types in a shared interface file.
Quoted 7 lines
?
what is a "shared interface file" ?
That doesn't sound like a linux thing
Jason
Nothing particularly related to linux, just a common practice of having the same interface on both sides (driver and device in this case).
Michael
Jason Gunthorpe
maintainerQuoted 8 lines · Michael
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Actually that's wrong, the device always sets guid in BE order so no swap is needed in the driver in any case.
They you just mark it as
_be64in the struct and there is no reason for the__force?That's probably the most correct way but I prefer to avoid introducing kernel specific types in a shared interface file.
Quoted 8 lines
Quoted 5 lines
?
what is a "shared interface file" ?
That doesn't sound like a linux thing
Nothing particularly related to linux, just a common practice of having the same interface on both sides (driver and device in this case).
Well, you still have to use correct types in the linux headers and work that out somehow
Jason
Quoted 20 lines · Michael Margolin
The GUID is received in big-endian so align types accordingly to avoid compiler warnings.
Fixes 04e36fd27a2a ("RDMA/efa: Add support for node guid")Reported-by kernel test robot <[email protected]>Reviewed-by Yehuda Yitschak <[email protected]>Reviewed-by Yonatan Nachum <[email protected]>Signed-off-by Michael Margolin <[email protected]>--- drivers/infiniband/hw/efa/efa_com_cmd.c | 2 +- drivers/infiniband/hw/efa/efa_com_cmd.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/hw/efa/efa_com_cmd.c +0
-0
drivers/infiniband/hw/efa/efa_com_cmd.c int efa_com_get_device_attr(struct efa_com_dev *edev, · line 468
Quoted 5 lines
drivers/infiniband/hw/efa/efa_com_cmd.c +1
-1@@ -465,7 +465,7 @@ int efa_com_get_device_attr(struct efa_com_dev *edev, result->db_bar = resp.u.device_attr.db_bar; result->max_rdma_size = resp.u.device_attr.max_rdma_size; result->device_caps = resp.u.device_attr.device_caps; - result->guid = resp.u.device_attr.guid; + result->guid = (__force __be64 )resp.u.device_attr.guid;
Based on the discussion, I'm dropping this patch.
Thanks