Skip to content

Commit 8039292

Browse files
committed
Merge tag 'cxl-fixes-for-6.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
Pull cxl fixes from Dan Williams: "A couple of fixes for bugs introduced during the merge window. One is a regression, the other was a bug in the CXL AER handler: - Fix a crash regression due to module load order of cxl_pmem.ko - Fix wrong register offset read in CXL AER handling path" * tag 'cxl-fixes-for-6.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl: cxl/pmem: Fix nvdimm unregistration when cxl_pmem driver is absent cxl: fix cxl_report_and_clear() RAS UE addr mis-assignment
2 parents 95e7a45 + 1939882 commit 8039292

File tree

4 files changed

+33
-41
lines changed

4 files changed

+33
-41
lines changed

drivers/cxl/acpi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,4 +736,3 @@ module_exit(cxl_acpi_exit);
736736
MODULE_LICENSE("GPL v2");
737737
MODULE_IMPORT_NS(CXL);
738738
MODULE_IMPORT_NS(ACPI);
739-
MODULE_SOFTDEP("pre: cxl_pmem");

drivers/cxl/core/pmem.c

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -227,34 +227,16 @@ static struct cxl_nvdimm *cxl_nvdimm_alloc(struct cxl_nvdimm_bridge *cxl_nvb,
227227
return cxl_nvd;
228228
}
229229

230-
static void cxl_nvd_unregister(void *_cxl_nvd)
230+
static void cxlmd_release_nvdimm(void *_cxlmd)
231231
{
232-
struct cxl_nvdimm *cxl_nvd = _cxl_nvd;
233-
struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
232+
struct cxl_memdev *cxlmd = _cxlmd;
233+
struct cxl_nvdimm *cxl_nvd = cxlmd->cxl_nvd;
234234
struct cxl_nvdimm_bridge *cxl_nvb = cxlmd->cxl_nvb;
235235

236-
/*
237-
* Either the bridge is in ->remove() context under the device_lock(),
238-
* or cxlmd_release_nvdimm() is cancelling the bridge's release action
239-
* for @cxl_nvd and doing it itself (while manually holding the bridge
240-
* lock).
241-
*/
242-
device_lock_assert(&cxl_nvb->dev);
243236
cxl_nvd->cxlmd = NULL;
244237
cxlmd->cxl_nvd = NULL;
238+
cxlmd->cxl_nvb = NULL;
245239
device_unregister(&cxl_nvd->dev);
246-
}
247-
248-
static void cxlmd_release_nvdimm(void *_cxlmd)
249-
{
250-
struct cxl_memdev *cxlmd = _cxlmd;
251-
struct cxl_nvdimm_bridge *cxl_nvb = cxlmd->cxl_nvb;
252-
253-
device_lock(&cxl_nvb->dev);
254-
if (cxlmd->cxl_nvd)
255-
devm_release_action(&cxl_nvb->dev, cxl_nvd_unregister,
256-
cxlmd->cxl_nvd);
257-
device_unlock(&cxl_nvb->dev);
258240
put_device(&cxl_nvb->dev);
259241
}
260242

@@ -293,22 +275,6 @@ int devm_cxl_add_nvdimm(struct cxl_memdev *cxlmd)
293275

294276
dev_dbg(&cxlmd->dev, "register %s\n", dev_name(dev));
295277

296-
/*
297-
* The two actions below arrange for @cxl_nvd to be deleted when either
298-
* the top-level PMEM bridge goes down, or the endpoint device goes
299-
* through ->remove().
300-
*/
301-
device_lock(&cxl_nvb->dev);
302-
if (cxl_nvb->dev.driver)
303-
rc = devm_add_action_or_reset(&cxl_nvb->dev, cxl_nvd_unregister,
304-
cxl_nvd);
305-
else
306-
rc = -ENXIO;
307-
device_unlock(&cxl_nvb->dev);
308-
309-
if (rc)
310-
goto err_alloc;
311-
312278
/* @cxlmd carries a reference on @cxl_nvb until cxlmd_release_nvdimm */
313279
return devm_add_action_or_reset(&cxlmd->dev, cxlmd_release_nvdimm, cxlmd);
314280

drivers/cxl/pci.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,11 @@ static bool cxl_report_and_clear(struct cxl_dev_state *cxlds)
554554

555555
/* If multiple errors, log header points to first error from ctrl reg */
556556
if (hweight32(status) > 1) {
557-
addr = cxlds->regs.ras + CXL_RAS_CAP_CONTROL_OFFSET;
558-
fe = BIT(FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK, readl(addr)));
557+
void __iomem *rcc_addr =
558+
cxlds->regs.ras + CXL_RAS_CAP_CONTROL_OFFSET;
559+
560+
fe = BIT(FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK,
561+
readl(rcc_addr)));
559562
} else {
560563
fe = status;
561564
}

drivers/cxl/pmem.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,35 @@ static int cxl_pmem_ctl(struct nvdimm_bus_descriptor *nd_desc,
225225
return cxl_pmem_nvdimm_ctl(nvdimm, cmd, buf, buf_len);
226226
}
227227

228+
static int detach_nvdimm(struct device *dev, void *data)
229+
{
230+
struct cxl_nvdimm *cxl_nvd;
231+
bool release = false;
232+
233+
if (!is_cxl_nvdimm(dev))
234+
return 0;
235+
236+
device_lock(dev);
237+
if (!dev->driver)
238+
goto out;
239+
240+
cxl_nvd = to_cxl_nvdimm(dev);
241+
if (cxl_nvd->cxlmd && cxl_nvd->cxlmd->cxl_nvb == data)
242+
release = true;
243+
out:
244+
device_unlock(dev);
245+
if (release)
246+
device_release_driver(dev);
247+
return 0;
248+
}
249+
228250
static void unregister_nvdimm_bus(void *_cxl_nvb)
229251
{
230252
struct cxl_nvdimm_bridge *cxl_nvb = _cxl_nvb;
231253
struct nvdimm_bus *nvdimm_bus = cxl_nvb->nvdimm_bus;
232254

255+
bus_for_each_dev(&cxl_bus_type, NULL, cxl_nvb, detach_nvdimm);
256+
233257
cxl_nvb->nvdimm_bus = NULL;
234258
nvdimm_bus_unregister(nvdimm_bus);
235259
}

0 commit comments

Comments
 (0)