drivers/fwctl/pds/main.c:113:65: sparse: sparse: restricted __le32 degrades to integer

kernel test robot
2025-04-01T18:47:22Z

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 08733088b566b58283f0f12fb73f5db6a9a9de30
commit: 92c66ee829b99a860a90f62ef16df3e42f92edac pds_fwctl: add rpc and query support
date: 11 days ago
config: loongarch-randconfig-r111-20250401 (https://download.01.org/0day-ci/archive/20250402/202504020246.Dfbhxoo9-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 14.2.0
reproduce: (https://download.01.org/0day-ci/archive/20250402/202504020246.Dfbhxoo9-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504020246.Dfbhxoo9-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/fwctl/pds/main.c:113:65: sparse: sparse: restricted __le32 degrades to integer
>> drivers/fwctl/pds/main.c:202:50: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] endpoint @@ got restricted __le32 [usertype] id @@
drivers/fwctl/pds/main.c:202:50: sparse: expected unsigned int [usertype] endpoint
drivers/fwctl/pds/main.c:202:50: sparse: got restricted __le32 [usertype] id
drivers/fwctl/pds/main.c:250:29: sparse: sparse: restricted __le32 degrades to integer
drivers/fwctl/pds/main.c:288:39: sparse: sparse: restricted __le32 degrades to integer
drivers/fwctl/pds/main.c:294:40: sparse: sparse: restricted __le32 degrades to integer
drivers/fwctl/pds/main.c:300:41: sparse: sparse: restricted __le32 degrades to integer
drivers/fwctl/pds/main.c:329:44: sparse: sparse: restricted __le32 degrades to integer
>> drivers/fwctl/pds/main.c:330:21: sparse: sparse: cast to restricted __le32
drivers/fwctl/pds/main.c:330:21: sparse: sparse: restricted __le32 degrades to integer
drivers/fwctl/pds/main.c:330:21: sparse: sparse: restricted __le32 degrades to integer
>> drivers/fwctl/pds/main.c:330:21: sparse: sparse: cast to restricted __le32
drivers/fwctl/pds/main.c:330:21: sparse: sparse: restricted __le32 degrades to integer
drivers/fwctl/pds/main.c:330:21: sparse: sparse: restricted __le32 degrades to integer
>> drivers/fwctl/pds/main.c:405:56: sparse: sparse: incorrect type in initializer (different base types) @@ expected restricted __le16 [usertype] flags @@ got int @@
drivers/fwctl/pds/main.c:405:56: sparse: expected restricted __le16 [usertype] flags
drivers/fwctl/pds/main.c:405:56: sparse: got int

vim +113 drivers/fwctl/pds/main.c

104
105 static void pdsfc_free_endpoints(struct pdsfc_dev *pdsfc)
106 {
107 struct device *dev = &pdsfc->fwctl.dev;
108 int i;
109
110 if (!pdsfc->endpoints)
111 return;
112
> 113 for (i = 0; pdsfc->endpoint_info && i < pdsfc->endpoints->num_entries; i++)
114 mutex_destroy(&pdsfc->endpoint_info[i].lock);
115 vfree(pdsfc->endpoint_info);
116 pdsfc->endpoint_info = NULL;
117 dma_free_coherent(dev->parent, PAGE_SIZE,
118 pdsfc->endpoints, pdsfc->endpoints_pa);
119 pdsfc->endpoints = NULL;
120 pdsfc->endpoints_pa = DMA_MAPPING_ERROR;
121 }
122
123 static void pdsfc_free_operations(struct pdsfc_dev *pdsfc)
124 {
125 struct device *dev = &pdsfc->fwctl.dev;
126 u32 num_endpoints;
127 int i;
128
129 num_endpoints = le32_to_cpu(pdsfc->endpoints->num_entries);
130 for (i = 0; i < num_endpoints; i++) {
131 struct pdsfc_rpc_endpoint_info *ei = &pdsfc->endpoint_info[i];
132
133 if (ei->operations) {
134 dma_free_coherent(dev->parent, PAGE_SIZE,
135 ei->operations, ei->operations_pa);
136 ei->operations = NULL;
137 ei->operations_pa = DMA_MAPPING_ERROR;
138 }
139 }
140 }
141
142 static struct pds_fwctl_query_data *pdsfc_get_endpoints(struct pdsfc_dev *pdsfc,
143 dma_addr_t *pa)
144 {
145 struct device *dev = &pdsfc->fwctl.dev;
146 union pds_core_adminq_comp comp = {0};
147 struct pds_fwctl_query_data *data;
148 union pds_core_adminq_cmd cmd;
149 dma_addr_t data_pa;
150 int err;
151
152 data = dma_alloc_coherent(dev->parent, PAGE_SIZE, &data_pa, GFP_KERNEL);
153 if (!data) {
154 dev_err(dev, "Failed to map endpoint list\n");
155 return ERR_PTR(-ENOMEM);
156 }
157
158 cmd = (union pds_core_adminq_cmd) {
159 .fwctl_query = {
160 .opcode = PDS_FWCTL_CMD_QUERY,
161 .entity = PDS_FWCTL_RPC_ROOT,
162 .version = 0,
163 .query_data_buf_len = cpu_to_le32(PAGE_SIZE),
164 .query_data_buf_pa = cpu_to_le64(data_pa),
165 }
166 };
167
168 err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0);
169 if (err) {
170 dev_err(dev, "Failed to send adminq cmd opcode: %u entity: %u err: %d\n",
171 cmd.fwctl_query.opcode, cmd.fwctl_query.entity, err);
172 dma_free_coherent(dev->parent, PAGE_SIZE, data, data_pa);
173 return ERR_PTR(err);
174 }
175
176 *pa = data_pa;
177
178 return data;
179 }
180
181 static int pdsfc_init_endpoints(struct pdsfc_dev *pdsfc)
182 {
183 struct pds_fwctl_query_data_endpoint *ep_entry;
184 u32 num_endpoints;
185 int i;
186
187 pdsfc->endpoints = pdsfc_get_endpoints(pdsfc, &pdsfc->endpoints_pa);
188 if (IS_ERR(pdsfc->endpoints))
189 return PTR_ERR(pdsfc->endpoints);
190
191 num_endpoints = le32_to_cpu(pdsfc->endpoints->num_entries);
192 pdsfc->endpoint_info = vcalloc(num_endpoints,
193 sizeof(*pdsfc->endpoint_info));
194 if (!pdsfc->endpoint_info) {
195 pdsfc_free_endpoints(pdsfc);
196 return -ENOMEM;
197 }
198
199 ep_entry = (struct pds_fwctl_query_data_endpoint *)pdsfc->endpoints->entries;
200 for (i = 0; i < num_endpoints; i++) {
201 mutex_init(&pdsfc->endpoint_info[i].lock);
> 202 pdsfc->endpoint_info[i].endpoint = ep_entry[i].id;
203 }
204
205 return 0;
206 }
207

--
0-DAY CI Kernel Test Service