On 2021/3/24 3:56, Jason Gunthorpe wrote: > On Fri, Mar 12, 2021 at 05:48:26PM +0800, Weihang Li wrote: > >> +static int hns_roce_query_func_info(struct hns_roce_dev *hr_dev) >> +{ >> + struct hns_roce_pf_func_info *resp; >> + struct hns_roce_cmq_desc desc; >> + int ret; >> + >> + if (hr_dev->pci_dev->revision < PCI_REVISION_ID_HIP09) >> + return 0; >> + >> + hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_QUERY_FUNC_INFO, >> + true); >> + ret = hns_roce_cmq_send(hr_dev, &desc, 1); >> + if (ret) >> + return ret; >> + >> + resp = (struct hns_roce_pf_func_info *)desc.data; > > WTF is this cast? > > struct hns_roce_cmq_desc { > __le16 opcode; > __le16 flag; > __le16 retval; > __le16 rsv; > __le32 data[6]; > }; > > Casting __le32 to a pointer is wrong > > Jason > Hi Jason desc.data is the address of array 'data[6]', it is got from the firmware, we cast it to 'struct hns_roce_pf_func_info *' to parse its contents. I think this is a cast from '__le32 *' to 'struct hns_roce_pf_func_info *'. Thanks Weihang