All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-xe] [PATCH 1/2] devcoredump: Add dev_coredump_put()
@ 2023-11-23 18:06 José Roberto de Souza
  2023-11-23 18:06 ` [Intel-xe] [PATCH 2/2] drm/xe: Remove devcoredump during driver release José Roberto de Souza
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: José Roberto de Souza @ 2023-11-23 18:06 UTC (permalink / raw)
  To: intel-xe; +Cc: Rodrigo Vivi

Add function to remove device coredump, this is useful to release
resources allocated by device before unload.
Without this coredump would only be removed after DEVCD_TIMEOUT
seconds.

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 drivers/base/devcoredump.c  | 21 +++++++++++++++++++++
 include/linux/devcoredump.h |  5 +++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c
index 91536ee05f144..444bb510b6ef4 100644
--- a/drivers/base/devcoredump.c
+++ b/drivers/base/devcoredump.c
@@ -304,6 +304,27 @@ 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 frees data and remove coredump,
+ * otherwise does nothing.
+ * This is useful to release resources allocated by device before unload it.
+ */
+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.42.1


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

end of thread, other threads:[~2023-11-28 21:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-23 18:06 [Intel-xe] [PATCH 1/2] devcoredump: Add dev_coredump_put() José Roberto de Souza
2023-11-23 18:06 ` [Intel-xe] [PATCH 2/2] drm/xe: Remove devcoredump during driver release José Roberto de Souza
2023-11-23 19:06 ` [Intel-xe] ✓ CI.Patch_applied: success for series starting with [1/2] devcoredump: Add dev_coredump_put() Patchwork
2023-11-23 19:07 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-11-23 19:08 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-11-23 19:15 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-11-23 19:15 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-11-23 19:17 ` [Intel-xe] ✓ CI.checksparse: " Patchwork
2023-11-28 21:45 ` [Intel-xe] [PATCH 1/2] " Rodrigo Vivi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.