]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.6-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Jan 2024 14:55:05 +0000 (15:55 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Jan 2024 14:55:05 +0000 (15:55 +0100)
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

queue-6.6/cxl-add-cxl_num_decoders_committed-usage-to-cxl_test.patch [new file with mode: 0644]
queue-6.6/cxl-hdm-fix-a-benign-lockdep-splat.patch [new file with mode: 0644]
queue-6.6/cxl-memdev-hold-region_rwsem-during-inject-and-clear-poison-ops.patch [new file with mode: 0644]
queue-6.6/series

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 (file)
index 0000000..5d671bb
--- /dev/null
@@ -0,0 +1,61 @@
+From e05501e8a84eee4f819f31b9ce663bddd01b3b69 Mon Sep 17 00:00:00 2001
+From: Dave Jiang <dave.jiang@intel.com>
+Date: Mon, 6 Nov 2023 10:26:45 -0700
+Subject: cxl: Add cxl_num_decoders_committed() usage to cxl_test
+
+From: Dave Jiang <dave.jiang@intel.com>
+
+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 <alison.schofield@intel.com>
+Signed-off-by: Dave Jiang <dave.jiang@intel.com>
+Reviewed-by: Fan Ni <fan.ni@samsung.com>
+Link: https://lore.kernel.org/r/169929160525.824083.11813222229025394254.stgit@djiang5-mobl3
+Signed-off-by: Dan Williams <dan.j.williams@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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 (file)
index 0000000..3cf6c71
--- /dev/null
@@ -0,0 +1,45 @@
+From 36a1c2ee50f573972aea3c3019555f47ee0094c0 Mon Sep 17 00:00:00 2001
+From: Dave Jiang <dave.jiang@intel.com>
+Date: Fri, 17 Nov 2023 13:18:48 -0700
+Subject: cxl/hdm: Fix a benign lockdep splat
+
+From: Dave Jiang <dave.jiang@intel.com>
+
+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 <dave.jiang@intel.com>
+Link: https://lore.kernel.org/r/170025232811.2147250.16376901801315194121.stgit@djiang5-mobl3
+Acked-by: Davidlohr Bueso <dave@stgolabs.net>
+Signed-off-by: Dan Williams <dan.j.williams@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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 (file)
index 0000000..be1a3d0
--- /dev/null
@@ -0,0 +1,94 @@
+From 0e33ac9c3ffe5e4f55c68345f44cea7fec2fe750 Mon Sep 17 00:00:00 2001
+From: Alison Schofield <alison.schofield@intel.com>
+Date: Sun, 26 Nov 2023 16:09:30 -0800
+Subject: cxl/memdev: Hold region_rwsem during inject and clear poison ops
+
+From: Alison Schofield <alison.schofield@intel.com>
+
+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 <alison.schofield@intel.com>
+Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
+Reviewed-by: Dave Jiang <dave.jiang@intel.com>
+Link: https://lore.kernel.org/r/08721dc1df0a51e4e38fecd02425c3475912dfd5.1701041440.git.alison.schofield@intel.com
+Signed-off-by: Dan Williams <dan.j.williams@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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;
+ }
index 75d585a2a4993f5ac963f68338b369407719e02b..d53bc2bcdc366809df0ad9c635f8d42e01c7b7b1 100644 (file)
@@ -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