Re: [PATCH 2/2] cxl: Fix race of nvdimm_bus for the nvdimm_bridge object

kernel test robot
2026-02-05T06:44:56Z

Hi Dave,

kernel test robot noticed the following build errors:

[auto build test ERROR on 18f7fcd5e69a04df57b563360b88be72471d6b62]

url: https://github.com/intel-lab-lkp/linux/commits/Dave-Jiang/cxl-test-Removal-of-nvdimm_bus_register-wrapper-in-cxl_test/20260205-081838
base: 18f7fcd5e69a04df57b563360b88be72471d6b62
patch link: https://lore.kernel.org/r/20260205001633.1813643-3-dave.jiang%40intel.com
patch subject: [PATCH 2/2] cxl: Fix race of nvdimm_bus for the nvdimm_bridge object
config: i386-randconfig-013-20260205 (https://download.01.org/0day-ci/archive/20260205/202602051405.Laq0NMV5-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260205/202602051405.Laq0NMV5-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/202602051405.Laq0NMV5-lkp@intel.com/

All errors (new ones prefixed by >>):

ld: drivers/cxl/core/pmem.o: in function `unregister_nvdimm_bus':
>> drivers/cxl/core/pmem.c:279:(.text+0x320): undefined reference to `nvdimm_bus_unregister'
ld: drivers/cxl/core/pmem.o: in function `devm_cxl_add_nvdimm_bridge':
>> drivers/cxl/core/pmem.c:349:(.text+0x473): undefined reference to `nvdimm_bus_register'
ld: drivers/cxl/core/pmem.o: in function `cxl_pmem_nvdimm_ctl':
>> drivers/cxl/core/pmem.c:236:(.text+0x91c): undefined reference to `nvdimm_provider_data'
>> ld: drivers/cxl/core/pmem.c:237:(.text+0x926): undefined reference to `nvdimm_cmd_mask'

vim +279 drivers/cxl/core/pmem.c

232
233 static int cxl_pmem_nvdimm_ctl(struct nvdimm *nvdimm, unsigned int cmd,
234 void *buf, unsigned int buf_len)
235 {
> 236 struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
> 237 unsigned long cmd_mask = nvdimm_cmd_mask(nvdimm);
238 struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
239 struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
240
241 if (!test_bit(cmd, &cmd_mask))
242 return -ENOTTY;
243
244 switch (cmd) {
245 case ND_CMD_GET_CONFIG_SIZE:
246 return cxl_pmem_get_config_size(mds, buf, buf_len);
247 case ND_CMD_GET_CONFIG_DATA:
248 return cxl_pmem_get_config_data(mds, buf, buf_len);
249 case ND_CMD_SET_CONFIG_DATA:
250 return cxl_pmem_set_config_data(mds, buf, buf_len);
251 default:
252 return -ENOTTY;
253 }
254 }
255
256 static int cxl_pmem_ctl(struct nvdimm_bus_descriptor *nd_desc,
257 struct nvdimm *nvdimm, unsigned int cmd, void *buf,
258 unsigned int buf_len, int *cmd_rc)
259 {
260 /*
261 * No firmware response to translate, let the transport error
262 * code take precedence.
263 */
264 *cmd_rc = 0;
265
266 if (!nvdimm)
267 return -ENOTTY;
268 return cxl_pmem_nvdimm_ctl(nvdimm, cmd, buf, buf_len);
269 }
270
271 static void unregister_nvdimm_bus(void *_cxl_nvb)
272 {
273 struct cxl_nvdimm_bridge *cxl_nvb = _cxl_nvb;
274 struct nvdimm_bus *nvdimm_bus = cxl_nvb->nvdimm_bus;
275
276 bus_for_each_dev(&cxl_bus_type, NULL, cxl_nvb, detach_nvdimm);
277
278 cxl_nvb->nvdimm_bus = NULL;
> 279 nvdimm_bus_unregister(nvdimm_bus);
280 }
281
282 DEFINE_FREE(put_cxl_nvb, struct cxl_nvdimm_bridge *, if (!IS_ERR_OR_NULL(_T)) put_device(&_T->dev))
283 static struct cxl_nvdimm_bridge *
284 __devm_cxl_add_nvdimm_bridge(struct device *host, struct cxl_port *port)
285 {
286 struct device *dev;
287 int rc;
288
289 if (!IS_ENABLED(CONFIG_CXL_PMEM))
290 return ERR_PTR(-ENXIO);
291
292 struct cxl_nvdimm_bridge *cxl_nvb __free(put_cxl_nvb) =
293 cxl_nvdimm_bridge_alloc(port);
294 if (IS_ERR(cxl_nvb))
295 return cxl_nvb;
296
297 dev = &cxl_nvb->dev;
298 rc = dev_set_name(dev, "nvdimm-bridge%d", cxl_nvb->id);
299 if (rc)
300 return ERR_PTR(rc);
301
302 rc = device_add(dev);
303 if (rc)
304 return ERR_PTR(rc);
305
306 rc = devm_add_action_or_reset(host, unregister_nvb, cxl_nvb);
307 if (rc) {
308 retain_and_null_ptr(cxl_nvb);
309 return ERR_PTR(rc);
310 }
311
312 return no_free_ptr(cxl_nvb);
313 }
314
315 static void release_nvb(void *_cxl_nvb)
316 {
317 struct cxl_nvdimm_bridge *cxl_nvb = _cxl_nvb;
318
319 devm_release_action(&cxl_nvb->dev, unregister_nvb, cxl_nvb);
320 }
321
322 DEFINE_FREE(release_cxl_nvb, struct cxl_nvdimm_bridge *, if (!IS_ERR_OR_NULL(_T)) release_nvb(_T))
323 /**
324 * devm_cxl_add_nvdimm_bridge() - add the root of a LIBNVDIMM topology
325 * @host: platform firmware root device
326 * @port: CXL port at the root of a CXL topology
327 *
328 * Return: bridge device that can host cxl_nvdimm objects
329 */
330 struct cxl_nvdimm_bridge *devm_cxl_add_nvdimm_bridge(struct device *host,
331 struct cxl_port *port)
332 {
333 struct device *dev;
334 int rc;
335
336 struct cxl_nvdimm_bridge *cxl_nvb __free(release_cxl_nvb) =
337 __devm_cxl_add_nvdimm_bridge(host, port);
338 if (IS_ERR(cxl_nvb))
339 return cxl_nvb;
340
341 dev = &cxl_nvb->dev;
342 cxl_nvb->nd_desc = (struct nvdimm_bus_descriptor) {
343 .provider_name = dev_name(dev->parent->parent),
344 .module = THIS_MODULE,
345 .ndctl = cxl_pmem_ctl,
346 };
347
348 cxl_nvb->nvdimm_bus =
> 349 nvdimm_bus_register(&cxl_nvb->dev, &cxl_nvb->nd_desc);
350 if (!cxl_nvb->nvdimm_bus)
351 return ERR_PTR(-ENOMEM);
352
353 rc = devm_add_action_or_reset(dev, unregister_nvdimm_bus, cxl_nvb);
354 if (rc)
355 return ERR_PTR(rc);
356
357 return no_free_ptr(cxl_nvb);
358 }
359

--
0-DAY CI Kernel Test Service