]> git.baikalelectronics.ru Git - kernel.git/commit
cxl/mem: Fix synchronization mechanism for device removal vs ioctl operations
authorDan Williams <dan.j.williams@intel.com>
Thu, 1 Apr 2021 14:33:19 +0000 (07:33 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 6 Apr 2021 18:41:30 +0000 (11:41 -0700)
commit7f0467ad4b410f81bf4003246051da4b874012b4
tree26d67ea57a15e33606c0a064f76b6f0f6ca51caf
parent738705e1f0d6c4ed6a689be7fd0738cff52ec392
cxl/mem: Fix synchronization mechanism for device removal vs ioctl operations

The percpu_ref to gate whether cxl_memdev_ioctl() is free to use the
driver context (@cxlm) to issue I/O is overkill, implemented incorrectly
(missing a device reference before accessing the percpu_ref), and the
complexities of shutting down a percpu_ref contributed to a bug in the
error unwind in cxl_mem_add_memdev() (missing put_device() to be fixed
separately).

Use an rwsem to explicitly synchronize the usage of cxlmd->cxlm, and add
the missing reference counting for cxlmd in cxl_memdev_open() and
cxl_memdev_release_file().

Fixes: 841d25838973 ("cxl/mem: Register CXL memX devices")
Reported-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/161728759948.2474381.17481500816783671817.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/mem.c