From: Nathan Fontenot <nathan.fontenot@amd.com>
To: <linux-cxl@vger.kernel.org>
Cc: <dan.j.williams@intel.com>, <alison.schofield@intel.com>,
<linux-mm@kvack.org>, <gourry@gourry.net>
Subject: [PATCH v2 4/4] Add SOFT RESERVE resource notification chain
Date: Thu, 16 Jan 2025 11:42:08 -0600 [thread overview]
Message-ID: <fd3681b9860aea3367432935c4f4975e84e9d9b0.1737046620.git.nathan.fontenot@amd.com> (raw)
In-Reply-To: <cover.1737046620.git.nathan.fontenot@amd.com>
Add a notification chain for SOFT RESERVE resources that are added
to the iomem resource tree when the SOFT_RESERVE_MANAGED config
option is specified.
Update the dax driver to register a notification handler for SOFT
RESERVE resources so that any late added SOFT RESERVES can be
consumed by the driver.
Signed-off-by: Nathan Fontenot <nathan.fontenot@amd.com>
---
drivers/dax/hmem/hmem.c | 24 +++++++++++++++++++++++-
include/linux/ioport.h | 11 +++++++++++
kernel/resource.c | 21 +++++++++++++++++++++
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c
index 088f4060d4d5..0e6b7558ca3d 100644
--- a/drivers/dax/hmem/hmem.c
+++ b/drivers/dax/hmem/hmem.c
@@ -126,14 +126,36 @@ static int hmem_register_device(const struct resource *res)
return rc;
}
+static int dax_hmem_cb(struct notifier_block *nb, unsigned long action,
+ void *arg)
+{
+ return hmem_register_device((struct resource *)arg);
+}
+
+static struct notifier_block dax_hmem_nb = {
+ .notifier_call = dax_hmem_cb,
+};
+
static int dax_hmem_platform_probe(struct platform_device *pdev)
{
+ int rc;
+
dax_hmem_pdev = pdev;
- return walk_hmem_resources(hmem_register_device);
+ rc = walk_hmem_resources(hmem_register_device);
+
+ register_srmem_notifier(&dax_hmem_nb);
+ return rc;
+}
+
+static void dax_hmem_platform_remove(struct platform_device *pdev)
+{
+ dax_hmem_pdev = NULL;
+ unregister_srmem_notifier(&dax_hmem_nb);
}
static struct platform_driver dax_hmem_platform_driver = {
.probe = dax_hmem_platform_probe,
+ .remove = dax_hmem_platform_remove,
.driver = {
.name = "hmem_platform",
},
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 2c95cf0be45e..c173cdd5ab87 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -13,6 +13,7 @@
#include <linux/bits.h>
#include <linux/compiler.h>
#include <linux/minmax.h>
+#include <linux/notifier.h>
#include <linux/types.h>
/*
* Resources are tree-like, allowing
@@ -254,8 +255,18 @@ resource_size_t resource_alignment(struct resource *res);
void merge_srmem_resources(void);
extern void release_srmem_region_adjustable(resource_size_t start,
resource_size_t size);
+int register_srmem_notifier(struct notifier_block *nb);
+int unregister_srmem_notifier(struct notifier_block *nb);
#else
static inline void merge_srmem_resources(void) { }
+static int register_srmem_notifier(struct notifier_block *nb)
+{
+ return 0;
+}
+static int unregister_srmem_notifier(struct notifier_block *nb)
+{
+ return 0;
+}
#endif
static inline resource_size_t resource_size(const struct resource *res)
diff --git a/kernel/resource.c b/kernel/resource.c
index 9db420078a3f..3e117e3ba2a5 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1471,6 +1471,26 @@ static void release_region_adjustable(struct resource *parent,
}
#ifdef CONFIG_SOFT_RESERVED_MANAGED
+
+static RAW_NOTIFIER_HEAD(srmem_chain);
+
+int register_srmem_notifier(struct notifier_block *nb)
+{
+ return raw_notifier_chain_register(&srmem_chain, nb);
+}
+EXPORT_SYMBOL(register_srmem_notifier);
+
+int unregister_srmem_notifier(struct notifier_block *nb)
+{
+ return raw_notifier_chain_unregister(&srmem_chain, nb);
+}
+EXPORT_SYMBOL(unregister_srmem_notifier);
+
+static int srmem_notify(void *v)
+{
+ return raw_notifier_call_chain(&srmem_chain, 0, v);
+}
+
/**
* merge_srmem_resources - merge srmem resources into the iomem resource tree
*
@@ -1497,6 +1517,7 @@ void merge_srmem_resources(void)
__insert_resource(&srmem_resource, res);
write_unlock(&resource_lock);
+ srmem_notify(res);
}
}
EXPORT_SYMBOL_GPL(merge_srmem_resources);
--
2.43.0
prev parent reply other threads:[~2025-01-16 17:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 17:42 [PATCH v2 0/4] Add managed SOFT RESERVE resource handling Nathan Fontenot
2025-01-16 17:42 ` [PATCH v2 1/4] kernel/resource: Introduce managed SOFT RESERVED resources Nathan Fontenot
2025-01-21 8:19 ` David Hildenbrand
2025-01-21 18:57 ` Fontenot, Nathan
2025-01-22 6:03 ` Fan Ni
2025-01-23 15:49 ` Fontenot, Nathan
2025-01-27 14:40 ` David Hildenbrand
2025-01-27 18:46 ` Fontenot, Nathan
2025-03-07 5:56 ` Zhijian Li (Fujitsu)
2025-03-07 16:47 ` Alison Schofield
2025-03-10 5:52 ` Li Zhijian
2025-03-07 23:05 ` Bowman, Terry
2025-03-10 6:00 ` Zhijian Li (Fujitsu)
2025-03-23 8:24 ` Zhijian Li (Fujitsu)
2025-03-23 8:33 ` Zhijian Li (Fujitsu)
2025-01-22 5:52 ` Fan Ni
2025-01-23 15:55 ` Fontenot, Nathan
2025-01-16 17:42 ` [PATCH v2 2/4] cxl: Update Soft Reserve resources upon region creation Nathan Fontenot
2025-01-16 17:42 ` [PATCH v2 3/4] dax: Update hmem resource/device registration Nathan Fontenot
2025-01-16 22:28 ` Ira Weiny
2025-01-21 18:49 ` Fontenot, Nathan
2025-01-21 23:14 ` Ira Weiny
2025-01-23 16:01 ` Fontenot, Nathan
2025-01-27 18:44 ` Fontenot, Nathan
2025-01-16 17:42 ` Nathan Fontenot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fd3681b9860aea3367432935c4f4975e84e9d9b0.1737046620.git.nathan.fontenot@amd.com \
--to=nathan.fontenot@amd.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=gourry@gourry.net \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox