linux-cxl.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/7] Add managed SOFT RESERVE resource handling
@ 2025-07-15 18:04 Smita Koralahalli
  2025-07-15 18:04 ` [PATCH v5 1/7] cxl/acpi: Refactor cxl_acpi_probe() to always schedule fallback DAX registration Smita Koralahalli
                   ` (9 more replies)
  0 siblings, 10 replies; 38+ messages in thread
From: Smita Koralahalli @ 2025-07-15 18:04 UTC (permalink / raw)
  To: linux-cxl, linux-kernel, nvdimm, linux-fsdevel, linux-pm
  Cc: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Ira Weiny, Dan Williams, Matthew Wilcox, Jan Kara,
	Rafael J . Wysocki, Len Brown, Pavel Machek, Li Ming,
	Jeff Johnson, Ying Huang, Yao Xingtao, Peter Zijlstra, Greg KH,
	Nathan Fontenot, Smita Koralahalli, Terry Bowman, Robert Richter,
	Benjamin Cheatham, PradeepVineshReddy Kodamati, Zhijian Li

This series introduces the ability to manage SOFT RESERVED iomem
resources, enabling the CXL driver to remove any portions that
intersect with created CXL regions.

The current approach of leaving SOFT RESERVED entries as is can result
in failures during device hotplug such as CXL because the address range
remains reserved and unavailable for reuse even after region teardown.

To address this, the CXL driver now uses a background worker that waits
for cxl_mem driver probe to complete before scanning for intersecting
resources. Then the driver walks through created CXL regions to trim any
intersections with SOFT RESERVED resources in the iomem tree.

The following scenarios have been tested:

Example 1: Exact alignment, soft reserved is a child of the region

|---------- "Soft Reserved" -----------|
|-------------- "Region #" ------------|

Before:
  1050000000-304fffffff : CXL Window 0
    1050000000-304fffffff : region0
      1050000000-304fffffff : Soft Reserved
        1080000000-2fffffffff : dax0.0
          1080000000-2fffffffff : System RAM (kmem)

After:
  1050000000-304fffffff : CXL Window 0
    1050000000-304fffffff : region0
      1080000000-2fffffffff : dax0.0
        1080000000-2fffffffff : System RAM (kmem)

Example 2: Start and/or end aligned and soft reserved spans multiple
regions
|----------- "Soft Reserved" -----------|
|-------- "Region #" -------|
or
|----------- "Soft Reserved" -----------|
            |-------- "Region #" -------|

Before:
  850000000-684fffffff : Soft Reserved
    850000000-284fffffff : CXL Window 0
      850000000-284fffffff : region3
        850000000-284fffffff : dax0.0
          850000000-284fffffff : System RAM (kmem)
    2850000000-484fffffff : CXL Window 1
      2850000000-484fffffff : region4
        2850000000-484fffffff : dax1.0
          2850000000-484fffffff : System RAM (kmem)
    4850000000-684fffffff : CXL Window 2
      4850000000-684fffffff : region5
        4850000000-684fffffff : dax2.0
          4850000000-684fffffff : System RAM (kmem)

After:
  850000000-284fffffff : CXL Window 0
    850000000-284fffffff : region3
      850000000-284fffffff : dax0.0
        850000000-284fffffff : System RAM (kmem)
  2850000000-484fffffff : CXL Window 1
    2850000000-484fffffff : region4
      2850000000-484fffffff : dax1.0
        2850000000-484fffffff : System RAM (kmem)
  4850000000-684fffffff : CXL Window 2
    4850000000-684fffffff : region5
      4850000000-684fffffff : dax2.0
        4850000000-684fffffff : System RAM (kmem)

Example 3: No alignment
|---------- "Soft Reserved" ----------|
	|---- "Region #" ----|

Before:
  00000000-3050000ffd : Soft Reserved
    ..
    ..
    1050000000-304fffffff : CXL Window 0
      1050000000-304fffffff : region1
        1080000000-2fffffffff : dax0.0
          1080000000-2fffffffff : System RAM (kmem)

After:
  00000000-104fffffff : Soft Reserved
    ..
    ..
  1050000000-304fffffff : CXL Window 0
    1050000000-304fffffff : region1
      1080000000-2fffffffff : dax0.0
        1080000000-2fffffffff : System RAM (kmem)
  3050000000-3050000ffd : Soft Reserved

Link to v4:
https://lore.kernel.org/linux-cxl/20250603221949.53272-1-Smita.KoralahalliChannabasappa@amd.com

v5 updates:
 - Handled cases where CXL driver loads early even before HMEM driver is
   initialized.
 - Introduced callback functions to resolve dependencies.
 - Rename suspend.c to probe_state.c.
 - Refactor cxl_acpi_probe() to use a single exit path.
 - Commit description update to justify cxl_mem_active() usage.
 - Change from kmalloc -> kzalloc in add_soft_reserved().
 - Change from goto to if else blocks inside remove_soft_reserved().
 - DEFINE_RES_MEM_NAMED -> DEFINE_RES_NAMED_DESC.
 - Comments for flags inside remove_soft_reserved().
 - Add resource_lock inside normalize_resource().
 - bus_find_next_device -> bus_find_device.
 - Skip DAX consumption of soft reserves inside hmat with
   CONFIG_CXL_ACPI checks.

v4 updates:
 - Split first patch into 4 smaller patches.
 - Correct the logic for cxl_pci_loaded() and cxl_mem_active() to return
   false at default instead of true.
 - Cleanup cxl_wait_for_pci_mem() to remove config checks for cxl_pci
   and cxl_mem.
 - Fixed multiple bugs and build issues which includes correcting
   walk_iomem_resc_desc() and calculations of alignments.
 
v3 updates:
 - Remove srmem resource tree from kernel/resource.c, this is no longer
   needed in the current implementation. All SOFT RESERVE resources now
   put on the iomem resource tree.
 - Remove the no longer needed SOFT_RESERVED_MANAGED kernel config option.
 - Add the 'nid' parameter back to hmem_register_resource();
 - Remove the no longer used soft reserve notification chain (introduced
   in v2). The dax driver is now notified of SOFT RESERVED resources by
   the CXL driver.

v2 updates:
 - Add config option SOFT_RESERVE_MANAGED to control use of the
   separate srmem resource tree at boot.
 - Only add SOFT RESERVE resources to the soft reserve tree during
   boot, they go to the iomem resource tree after boot.
 - Remove the resource trimming code in the previous patch to re-use
   the existing code in kernel/resource.c
 - Add functionality for the cxl acpi driver to wait for the cxl PCI
   and mem drivers to load.

Smita Koralahalli (7):
  cxl/acpi: Refactor cxl_acpi_probe() to always schedule fallback DAX
    registration
  cxl/core: Rename suspend.c to probe_state.c and remove
    CONFIG_CXL_SUSPEND
  cxl/acpi: Add background worker to coordinate with cxl_mem probe
    completion
  cxl/region: Introduce SOFT RESERVED resource removal on region
    teardown
  dax/hmem: Save the DAX HMEM platform device pointer
  dax/hmem, cxl: Defer DAX consumption of SOFT RESERVED resources until
    after CXL region creation
  dax/hmem: Preserve fallback SOFT RESERVED regions if DAX HMEM loads
    late

 drivers/acpi/numa/hmat.c                      |   4 +
 drivers/cxl/Kconfig                           |   4 -
 drivers/cxl/acpi.c                            |  50 +++++--
 drivers/cxl/core/Makefile                     |   2 +-
 drivers/cxl/core/{suspend.c => probe_state.c} |  10 +-
 drivers/cxl/core/region.c                     | 135 ++++++++++++++++++
 drivers/cxl/cxl.h                             |   4 +
 drivers/cxl/cxlmem.h                          |   9 --
 drivers/dax/hmem/Makefile                     |   1 +
 drivers/dax/hmem/device.c                     |  62 ++++----
 drivers/dax/hmem/hmem.c                       |  14 +-
 drivers/dax/hmem/hmem_notify.c                |  29 ++++
 include/linux/dax.h                           |   7 +-
 include/linux/ioport.h                        |   1 +
 include/linux/pm.h                            |   7 -
 kernel/resource.c                             |  34 +++++
 16 files changed, 307 insertions(+), 66 deletions(-)
 rename drivers/cxl/core/{suspend.c => probe_state.c} (62%)
 create mode 100644 drivers/dax/hmem/hmem_notify.c

-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2025-09-01  2:47 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 18:04 [PATCH v5 0/7] Add managed SOFT RESERVE resource handling Smita Koralahalli
2025-07-15 18:04 ` [PATCH v5 1/7] cxl/acpi: Refactor cxl_acpi_probe() to always schedule fallback DAX registration Smita Koralahalli
2025-07-22 21:04   ` dan.j.williams
2025-07-23  0:45     ` Alison Schofield
2025-07-23  7:34       ` dan.j.williams
2025-07-15 18:04 ` [PATCH v5 2/7] cxl/core: Rename suspend.c to probe_state.c and remove CONFIG_CXL_SUSPEND Smita Koralahalli
2025-07-22 21:44   ` dan.j.williams
2025-07-15 18:04 ` [PATCH v5 3/7] cxl/acpi: Add background worker to coordinate with cxl_mem probe completion Smita Koralahalli
2025-07-17  0:24   ` Dave Jiang
2025-07-23  7:31   ` dan.j.williams
2025-07-23 16:13     ` dan.j.williams
2025-08-05  3:58       ` Zhijian Li (Fujitsu)
2025-08-20 23:14         ` Alison Schofield
2025-08-21  2:30           ` Zhijian Li (Fujitsu)
2025-08-22  3:56             ` Koralahalli Channabasappa, Smita
2025-08-25  7:50               ` Zhijian Li (Fujitsu)
2025-08-27  6:30                 ` Zhijian Li (Fujitsu)
2025-08-28 23:21                   ` Koralahalli Channabasappa, Smita
2025-09-01  2:46                     ` Zhijian Li (Fujitsu)
2025-07-29 15:48     ` Koralahalli Channabasappa, Smita
2025-07-30 16:09       ` dan.j.williams
2025-07-15 18:04 ` [PATCH v5 4/7] cxl/region: Introduce SOFT RESERVED resource removal on region teardown Smita Koralahalli
2025-07-17  0:42   ` Dave Jiang
2025-07-15 18:04 ` [PATCH v5 5/7] dax/hmem: Save the DAX HMEM platform device pointer Smita Koralahalli
2025-07-15 18:04 ` [PATCH v5 6/7] dax/hmem, cxl: Defer DAX consumption of SOFT RESERVED resources until after CXL region creation Smita Koralahalli
2025-07-15 18:04 ` [PATCH v5 7/7] dax/hmem: Preserve fallback SOFT RESERVED regions if DAX HMEM loads late Smita Koralahalli
2025-07-15 21:07 ` [PATCH v5 0/7] Add managed SOFT RESERVE resource handling Alison Schofield
2025-07-16  6:01   ` Koralahalli Channabasappa, Smita
2025-07-16 20:20     ` Alison Schofield
2025-07-16 21:29       ` Koralahalli Channabasappa, Smita
2025-07-16 23:48         ` Alison Schofield
2025-07-17 17:58           ` Koralahalli Channabasappa, Smita
2025-07-17 19:06             ` Dave Jiang
2025-07-17 23:20               ` Koralahalli Channabasappa, Smita
2025-07-17 23:30                 ` Dave Jiang
2025-07-23 15:24     ` dan.j.williams
2025-07-21  7:38 ` Zhijian Li (Fujitsu)
2025-07-22 20:07 ` dan.j.williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).