From: "José Roberto de Souza" <jose.souza@intel.com>
To: linux-kernel@vger.kernel.org, intel-xe@lists.freedesktop.org
Cc: "Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Mukesh Ojha" <quic_mojha@quicinc.com>,
"Johannes Berg" <johannes@sipsolutions.net>,
"Jonathan Cavitt" <jonathan.cavitt@intel.com>,
"José Roberto de Souza" <jose.souza@intel.com>
Subject: [PATCH v4 1/2] devcoredump: Add dev_coredump_put()
Date: Tue, 9 Apr 2024 13:02:05 -0700 [thread overview]
Message-ID: <20240409200206.108452-1-jose.souza@intel.com> (raw)
It is useful for modules that do not want to keep coredump available
after its unload.
Otherwise, the coredump would only be removed after DEVCD_TIMEOUT
seconds.
v2:
- dev_coredump_put() documentation updated (Mukesh)
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Mukesh Ojha <quic_mojha@quicinc.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
drivers/base/devcoredump.c | 23 +++++++++++++++++++++++
include/linux/devcoredump.h | 5 +++++
2 files changed, 28 insertions(+)
diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c
index 7e2d1f0d903a6..82aeb09b3d1b5 100644
--- a/drivers/base/devcoredump.c
+++ b/drivers/base/devcoredump.c
@@ -304,6 +304,29 @@ static ssize_t devcd_read_from_sgtable(char *buffer, loff_t offset,
offset);
}
+/**
+ * dev_coredump_put - remove device coredump
+ * @dev: the struct device for the crashed device
+ *
+ * dev_coredump_put() removes coredump, if exists, for a given device from
+ * the file system and free its associated data otherwise, does nothing.
+ *
+ * It is useful for modules that do not want to keep coredump
+ * available after its unload.
+ */
+void dev_coredump_put(struct device *dev)
+{
+ struct device *existing;
+
+ existing = class_find_device(&devcd_class, NULL, dev,
+ devcd_match_failing);
+ if (existing) {
+ devcd_free(existing, NULL);
+ put_device(existing);
+ }
+}
+EXPORT_SYMBOL_GPL(dev_coredump_put);
+
/**
* dev_coredumpm - create device coredump with read/free methods
* @dev: the struct device for the crashed device
diff --git a/include/linux/devcoredump.h b/include/linux/devcoredump.h
index c008169ed2c6f..c8f7eb6cc1915 100644
--- a/include/linux/devcoredump.h
+++ b/include/linux/devcoredump.h
@@ -63,6 +63,8 @@ void dev_coredumpm(struct device *dev, struct module *owner,
void dev_coredumpsg(struct device *dev, struct scatterlist *table,
size_t datalen, gfp_t gfp);
+
+void dev_coredump_put(struct device *dev);
#else
static inline void dev_coredumpv(struct device *dev, void *data,
size_t datalen, gfp_t gfp)
@@ -85,6 +87,9 @@ static inline void dev_coredumpsg(struct device *dev, struct scatterlist *table,
{
_devcd_free_sgtable(table);
}
+static inline void dev_coredump_put(struct device *dev)
+{
+}
#endif /* CONFIG_DEV_COREDUMP */
#endif /* __DEVCOREDUMP_H */
--
2.44.0
next reply other threads:[~2024-04-09 20:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 20:02 José Roberto de Souza [this message]
2024-04-09 20:02 ` [PATCH v4 2/2] drm/xe: Remove devcoredump during driver release José Roberto de Souza
2024-04-09 22:21 ` Rodrigo Vivi
2024-04-09 20:07 ` ✓ CI.Patch_applied: success for series starting with [v4,1/2] devcoredump: Add dev_coredump_put() Patchwork
2024-04-09 20:07 ` ✗ CI.checkpatch: warning " Patchwork
2024-04-09 20:08 ` ✓ CI.KUnit: success " Patchwork
2024-04-09 20:19 ` ✓ CI.Build: " Patchwork
2024-04-09 20:22 ` ✓ CI.Hooks: " Patchwork
2024-04-09 20:23 ` ✓ CI.checksparse: " Patchwork
2024-04-09 20:48 ` ✓ CI.BAT: " Patchwork
2024-04-09 22:23 ` [PATCH v4 1/2] " Rodrigo Vivi
2024-04-11 13:08 ` Greg KH
2024-04-09 22:39 ` ✗ CI.FULL: failure for series starting with [v4,1/2] " Patchwork
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=20240409200206.108452-1-jose.souza@intel.com \
--to=jose.souza@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=johannes@sipsolutions.net \
--cc=jonathan.cavitt@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_mojha@quicinc.com \
--cc=rodrigo.vivi@intel.com \
/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