mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/4] devcoredump: Add dev_coredump_put()
@ 2024-02-27 21:00 José Roberto de Souza
  2024-02-27 21:00 ` [PATCH 2/4] devcoredump: Add dev_coredump_timeout_set() José Roberto de Souza
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: José Roberto de Souza @ 2024-02-27 21:00 UTC (permalink / raw)
  To: linux-kernel, intel-xe
  Cc: Rodrigo Vivi, Mukesh Ojha, Johannes Berg, Jonathan Cavitt,
	José Roberto de Souza

This is useful for drivers that don't want to keep a coredump
available after unloading.
Otherwise, the coredump would only be removed after DEVCD_TIMEOUT
seconds.

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>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 drivers/base/devcoredump.c  | 22 ++++++++++++++++++++++
 include/linux/devcoredump.h |  5 +++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c
index 7e2d1f0d903a6..e96427411b87c 100644
--- a/drivers/base/devcoredump.c
+++ b/drivers/base/devcoredump.c
@@ -304,6 +304,28 @@ 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
+ *
+ * If giving device has a coredump this removes it from file system and free
+ * associated data otherwise does nothing.
+ * This is useful for drivers that don't want to keep a coredump
+ * available after unloading.
+ */
+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


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

end of thread, other threads:[~2024-02-28 13:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 21:00 [PATCH 1/4] devcoredump: Add dev_coredump_put() José Roberto de Souza
2024-02-27 21:00 ` [PATCH 2/4] devcoredump: Add dev_coredump_timeout_set() José Roberto de Souza
2024-02-28  8:26   ` Mukesh Ojha
2024-02-28 13:12     ` Souza, Jose
2024-02-27 21:00 ` [PATCH 3/4] drm/xe: Remove devcoredump during driver release José Roberto de Souza
2024-02-27 21:00 ` [PATCH 4/4] drm/xe: Increase devcoredump timeout José Roberto de Souza
2024-02-28 13:42 ` [PATCH 1/4] devcoredump: Add dev_coredump_put() Mukesh Ojha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®