From: Greg Kroah-Hartman Date: Mon, 8 Jan 2024 14:55:05 +0000 (+0100) Subject: 6.6-stable patches X-Git-Tag: v4.14.336~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f299c66c9f8c92612c0c40c58ac5cb65e8a32fe;p=thirdparty%2Fkernel%2Fstable-queue.git 6.6-stable patches added patches: cxl-add-cxl_num_decoders_committed-usage-to-cxl_test.patch cxl-hdm-fix-a-benign-lockdep-splat.patch cxl-memdev-hold-region_rwsem-during-inject-and-clear-poison-ops.patch --- diff --git a/queue-6.6/cxl-add-cxl_num_decoders_committed-usage-to-cxl_test.patch b/queue-6.6/cxl-add-cxl_num_decoders_committed-usage-to-cxl_test.patch new file mode 100644 index 00000000000..5d671bb5e9d --- /dev/null +++ b/queue-6.6/cxl-add-cxl_num_decoders_committed-usage-to-cxl_test.patch @@ -0,0 +1,61 @@ +From e05501e8a84eee4f819f31b9ce663bddd01b3b69 Mon Sep 17 00:00:00 2001 +From: Dave Jiang +Date: Mon, 6 Nov 2023 10:26:45 -0700 +Subject: cxl: Add cxl_num_decoders_committed() usage to cxl_test + +From: Dave Jiang + +commit e05501e8a84eee4f819f31b9ce663bddd01b3b69 upstream. + +Commit 458ba8189cb4 ("cxl: Add cxl_decoders_committed() helper") missed the +conversion for cxl_test. Add usage of cxl_num_decoders_committed() to +replace the open coding. + +Suggested-by: Alison Schofield +Signed-off-by: Dave Jiang +Reviewed-by: Fan Ni +Link: https://lore.kernel.org/r/169929160525.824083.11813222229025394254.stgit@djiang5-mobl3 +Signed-off-by: Dan Williams +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/cxl/Kbuild | 1 + + tools/testing/cxl/cxl_core_exports.c | 7 +++++++ + tools/testing/cxl/test/cxl.c | 5 +++-- + 3 files changed, 11 insertions(+), 2 deletions(-) + create mode 100644 tools/testing/cxl/cxl_core_exports.c + +--- a/tools/testing/cxl/Kbuild ++++ b/tools/testing/cxl/Kbuild +@@ -62,5 +62,6 @@ cxl_core-$(CONFIG_TRACING) += $(CXL_CORE + cxl_core-$(CONFIG_CXL_REGION) += $(CXL_CORE_SRC)/region.o + cxl_core-y += config_check.o + cxl_core-y += cxl_core_test.o ++cxl_core-y += cxl_core_exports.o + + obj-m += test/ +--- /dev/null ++++ b/tools/testing/cxl/cxl_core_exports.c +@@ -0,0 +1,7 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* Copyright(c) 2022 Intel Corporation. All rights reserved. */ ++ ++#include "cxl.h" ++ ++/* Exporting of cxl_core symbols that are only used by cxl_test */ ++EXPORT_SYMBOL_NS_GPL(cxl_num_decoders_committed, CXL); +--- a/tools/testing/cxl/test/cxl.c ++++ b/tools/testing/cxl/test/cxl.c +@@ -669,10 +669,11 @@ static int mock_decoder_commit(struct cx + return 0; + + dev_dbg(&port->dev, "%s commit\n", dev_name(&cxld->dev)); +- if (port->commit_end + 1 != id) { ++ if (cxl_num_decoders_committed(port) != id) { + dev_dbg(&port->dev, + "%s: out of order commit, expected decoder%d.%d\n", +- dev_name(&cxld->dev), port->id, port->commit_end + 1); ++ dev_name(&cxld->dev), port->id, ++ cxl_num_decoders_committed(port)); + return -EBUSY; + } + diff --git a/queue-6.6/cxl-hdm-fix-a-benign-lockdep-splat.patch b/queue-6.6/cxl-hdm-fix-a-benign-lockdep-splat.patch new file mode 100644 index 00000000000..3cf6c713460 --- /dev/null +++ b/queue-6.6/cxl-hdm-fix-a-benign-lockdep-splat.patch @@ -0,0 +1,45 @@ +From 36a1c2ee50f573972aea3c3019555f47ee0094c0 Mon Sep 17 00:00:00 2001 +From: Dave Jiang +Date: Fri, 17 Nov 2023 13:18:48 -0700 +Subject: cxl/hdm: Fix a benign lockdep splat + +From: Dave Jiang + +commit 36a1c2ee50f573972aea3c3019555f47ee0094c0 upstream. + +The new helper "cxl_num_decoders_committed()" added a lockdep assertion +to validate that port->commit_end is protected against modification. +That assertion fires in init_hdm_decoder() where it is initializing +port->commit_end. Given that it is both accessing and writing that +property it obstensibly needs the lock. + +In practice, CXL decoder commit rules (must commit in order) and the +in-order discovery of device decoders makes the manipulation of +->commit_end in init_hdm_decoder() safe. However, rather than rely on +the subtle rules of CXL hardware, just make the implementation obviously +correct from a software perspective. + +The Fixes: tag is only for cleaning up a lockdep splat, there is no +functional issue addressed by this fix. + +Fixes: 458ba8189cb4 ("cxl: Add cxl_decoders_committed() helper") +Signed-off-by: Dave Jiang +Link: https://lore.kernel.org/r/170025232811.2147250.16376901801315194121.stgit@djiang5-mobl3 +Acked-by: Davidlohr Bueso +Signed-off-by: Dan Williams +Signed-off-by: Greg Kroah-Hartman +--- + drivers/cxl/core/hdm.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/cxl/core/hdm.c ++++ b/drivers/cxl/core/hdm.c +@@ -848,6 +848,8 @@ static int init_hdm_decoder(struct cxl_p + cxld->target_type = CXL_DECODER_HOSTONLYMEM; + else + cxld->target_type = CXL_DECODER_DEVMEM; ++ ++ guard(rwsem_write)(&cxl_region_rwsem); + if (cxld->id != cxl_num_decoders_committed(port)) { + dev_warn(&port->dev, + "decoder%d.%d: Committed out of order\n", diff --git a/queue-6.6/cxl-memdev-hold-region_rwsem-during-inject-and-clear-poison-ops.patch b/queue-6.6/cxl-memdev-hold-region_rwsem-during-inject-and-clear-poison-ops.patch new file mode 100644 index 00000000000..be1a3d08d0d --- /dev/null +++ b/queue-6.6/cxl-memdev-hold-region_rwsem-during-inject-and-clear-poison-ops.patch @@ -0,0 +1,94 @@ +From 0e33ac9c3ffe5e4f55c68345f44cea7fec2fe750 Mon Sep 17 00:00:00 2001 +From: Alison Schofield +Date: Sun, 26 Nov 2023 16:09:30 -0800 +Subject: cxl/memdev: Hold region_rwsem during inject and clear poison ops + +From: Alison Schofield + +commit 0e33ac9c3ffe5e4f55c68345f44cea7fec2fe750 upstream. + +Poison inject and clear are supported via debugfs where a privileged +user can inject and clear poison to a device physical address. + +Commit 458ba8189cb4 ("cxl: Add cxl_decoders_committed() helper") +added a lockdep assert that highlighted a gap in poison inject and +clear functions where holding the dpa_rwsem does not assure that a +a DPA is not added to a region. + +The impact for inject and clear is that if the DPA address being +injected or cleared has been attached to a region, but not yet +committed, the dev_dbg() message intended to alert the debug user +that they are acting on a mapped address is not emitted. Also, the +cxl_poison trace event that serves as a log of the inject and clear +activity will not include region info. + +Close this gap by snapshotting an unchangeable region state during +poison inject and clear operations. That means holding both the +region_rwsem and the dpa_rwsem during the inject and clear ops. + +Fixes: d2fbc4865802 ("cxl/memdev: Add support for the Inject Poison mailbox command") +Fixes: 9690b07748d1 ("cxl/memdev: Add support for the Clear Poison mailbox command") +Signed-off-by: Alison Schofield +Reviewed-by: Davidlohr Bueso +Reviewed-by: Dave Jiang +Link: https://lore.kernel.org/r/08721dc1df0a51e4e38fecd02425c3475912dfd5.1701041440.git.alison.schofield@intel.com +Signed-off-by: Dan Williams +Signed-off-by: Greg Kroah-Hartman +--- + drivers/cxl/core/memdev.c | 18 ++++++++++++++++-- + 1 file changed, 16 insertions(+), 2 deletions(-) + +--- a/drivers/cxl/core/memdev.c ++++ b/drivers/cxl/core/memdev.c +@@ -331,10 +331,16 @@ int cxl_inject_poison(struct cxl_memdev + if (!IS_ENABLED(CONFIG_DEBUG_FS)) + return 0; + +- rc = down_read_interruptible(&cxl_dpa_rwsem); ++ rc = down_read_interruptible(&cxl_region_rwsem); + if (rc) + return rc; + ++ rc = down_read_interruptible(&cxl_dpa_rwsem); ++ if (rc) { ++ up_read(&cxl_region_rwsem); ++ return rc; ++ } ++ + rc = cxl_validate_poison_dpa(cxlmd, dpa); + if (rc) + goto out; +@@ -362,6 +368,7 @@ int cxl_inject_poison(struct cxl_memdev + trace_cxl_poison(cxlmd, cxlr, &record, 0, 0, CXL_POISON_TRACE_INJECT); + out: + up_read(&cxl_dpa_rwsem); ++ up_read(&cxl_region_rwsem); + + return rc; + } +@@ -379,10 +386,16 @@ int cxl_clear_poison(struct cxl_memdev * + if (!IS_ENABLED(CONFIG_DEBUG_FS)) + return 0; + +- rc = down_read_interruptible(&cxl_dpa_rwsem); ++ rc = down_read_interruptible(&cxl_region_rwsem); + if (rc) + return rc; + ++ rc = down_read_interruptible(&cxl_dpa_rwsem); ++ if (rc) { ++ up_read(&cxl_region_rwsem); ++ return rc; ++ } ++ + rc = cxl_validate_poison_dpa(cxlmd, dpa); + if (rc) + goto out; +@@ -419,6 +432,7 @@ int cxl_clear_poison(struct cxl_memdev * + trace_cxl_poison(cxlmd, cxlr, &record, 0, 0, CXL_POISON_TRACE_CLEAR); + out: + up_read(&cxl_dpa_rwsem); ++ up_read(&cxl_region_rwsem); + + return rc; + } diff --git a/queue-6.6/series b/queue-6.6/series index 75d585a2a49..d53bc2bcdc3 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -118,3 +118,6 @@ mmc-meson-mx-sdhc-fix-initialization-frozen-issue.patch mmc-rpmb-fixes-pause-retune-on-all-rpmb-partitions.patch mmc-core-cancel-delayed-work-before-releasing-host.patch mmc-sdhci-sprd-fix-emmc-init-failure-after-hw-reset.patch +cxl-add-cxl_num_decoders_committed-usage-to-cxl_test.patch +cxl-hdm-fix-a-benign-lockdep-splat.patch +cxl-memdev-hold-region_rwsem-during-inject-and-clear-poison-ops.patch