Skip to contentSkip to conversation

clean up dma-buf-io kerneldocs

PATCH Superseded Pavel Begunkov 2 participants 5 messages Oct 16

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover clean up dma-buf-io kerneldocs

Add a kerneldoc for dma_buf_io_init_map() and clean up it overall. Targeting the Jens' branch where dma-buf-io sits. If preferred, it can all be squashed into

0d3120db2cbe0a ("dma-buf: introduce initial file I/O infrastructure")

Pavel Begunkov (2):
dma-buf-io: fix typos in kernel docs
dma-buf-io: document dma_buf_io_init_map

 drivers/dma-buf/dma-buf-io.c | 32 ++++++++++++++++++++++----------
 include/linux/dma-buf-io.h   |  7 ++++---
 2 files changed, 26 insertions(+), 13 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/2 dma-buf-io: fix typos in kernel docs

Fix some typos and inconsistencies in dma-buf-io kernel docs.

---
 drivers/dma-buf/dma-buf-io.c | 20 ++++++++++----------
 include/linux/dma-buf-io.h   |  7 ++++---
 2 files changed, 14 insertions(+), 13 deletions(-)
drivers/dma-buf/dma-buf-io.c +10 -10
index 21296bd3dde1..e432194a5dfc 100644
@@ -106,7 +106,7 @@ static struct dma_buf_io_map *__dma_buf_io_create_map(struct dma_buf_io_ctx *ctx
  * @ctx:	[in]	dma-buf I/O context
  *
  * A slow path part of dma_buf_io_get_map() and shouldn't be used directly.
- * Behaves in the same way but allowed to block.
+ * Behaves in the same way but is allowed to block.
  *
  * Returns a map on success, or ERR_PTR encoded errno otherwise.
  */
@@ -133,16 +133,16 @@ static void dma_buf_io_ctx_shutdown(struct dma_buf_io_ctx *ctx)
 }
 
 /*
- * dma_buf_io_ctx_create - create a new dma-buf I/O context for the given file.
+ * dma_buf_io_ctx_create - Create a new dma-buf I/O context for the given file.
  * @file: 	[in]	file for which the context is created
  * @dmabuf:	[in]	buffer to create a context from
  * @dir:	[in]	direction of DMA transfers
- * @out_ctx	[out]	resulting ctx
+ * @out_ctx:	[out]	resulting ctx
  *
  * Create a new I/O context from the given DMA buffer for the given file.
  * It only works with files implementing ->init_dma_buf_io_ctx and fails
  * with -EOPNOTSUPP otherwise. Once created, the user can create a map
- * and use it to issue I/O like read / write requests to @file.
+ * and use it to issue I/O, such as read/write requests, to @file.
  */
 int dma_buf_io_ctx_create(struct file *file,
 			   struct dma_buf *dmabuf,
@@ -180,7 +180,7 @@ int dma_buf_io_ctx_create(struct file *file,
 }
 
 /**
- * dma_buf_io_ctx_release - destroy the I/O context
+ * dma_buf_io_ctx_release - Destroy the I/O context
  * @ctx:	[in]	dma-buf I/O context
  *
  * Destroy the context. It makes sure all maps are waited on and destroyed,
@@ -201,11 +201,11 @@ void dma_buf_io_ctx_release(struct dma_buf_io_ctx *ctx)
 }
 
 /**
- * dma_buf_io_invalidate_mappings - invalidate the current map
+ * dma_buf_io_invalidate_mappings - Invalidate the current map
  * @ctx: 	[in]	dma-buf I/O context
  *
  * Importer's helper for invalidating the current map. Waits for all I/O
- * using the map to complete and destroyes the map. Called with the
+ * using the map to complete and destroys the map. Called with the
  * dma-buf reservation lock held.
  */
 void dma_buf_io_invalidate_mappings(struct dma_buf_io_ctx *ctx)
@@ -215,11 +215,11 @@ void dma_buf_io_invalidate_mappings(struct dma_buf_io_ctx *ctx)
 EXPORT_SYMBOL_NS_GPL(dma_buf_io_invalidate_mappings, "DMA_BUF");
 
 /**
- * dma_buf_io_detach - detach the @ctx from the importer.
+ * dma_buf_io_detach - Detach the @ctx from the importer.
  * @ctx:	[in]	dma-buf I/O context
  *
- * Importer's helper for removing the I/O ctx. It kills all maps and
- * prevents creation of new ones. Upon return it's safe for the importer
+ * Importer's helper for removing the I/O context. It kills all maps and
+ * prevents creation of new ones. Upon return, it's safe for the importer
  * to release all its resources such as dma-buf attachments.
  */
 void dma_buf_io_detach(struct dma_buf_io_ctx *ctx)
include/linux/dma-buf-io.h +4 -3
index b9bbeca1744f..d9f27650a851 100644
@@ -60,6 +60,7 @@ void dma_buf_io_ctx_release(struct dma_buf_io_ctx *ctx);
 
 struct dma_buf_io_map *dma_buf_io_create_map(struct dma_buf_io_ctx *ctx);
 
+/* Internal helper, see dma_buf_io_get_map() */
 static inline struct dma_buf_io_map *
 __dma_buf_io_get_map(struct dma_buf_io_ctx *ctx)
 {
@@ -79,10 +80,10 @@ __dma_buf_io_get_map(struct dma_buf_io_ctx *ctx)
  * @ctx:	[in]	dma-buf I/O context
  * @nowait:	[in]	specifies whether it's allowed to block
  *
- * Create a new or acquire an existing map. When succeeds, it returns
+ * Create a new or acquire an existing map. On success, it returns
  * a referenced map, which should eventually be put down with
  * dma_buf_io_map_drop(). If @nowait is set and the function would block,
- * it return -EAGAIN, and the caller is expected to retry from a context
+ * it returns -EAGAIN, and the caller is expected to retry from a context
  * where blocking is allowed.
  *
  * Returns a map on success, or ERR_PTR encoded errno otherwise.
@@ -105,7 +106,7 @@ dma_buf_io_get_map(struct dma_buf_io_ctx *ctx, bool nowait)
  * dma_buf_io_map_drop - Drop the map.
  * @map:	[in]	dma-buf I/O map
  *
- * Put down a reference for the @map acquired via dma_buf_io_get_map().
+ * Put down a reference to the @map acquired via dma_buf_io_get_map().
  * Should be called as soon as I/O is completed.
  */
 static inline void dma_buf_io_map_drop(struct dma_buf_io_map *map)
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/2 dma-buf-io: document dma_buf_io_init_map

In reply to Pavel Begunkov

Add a kerneldoc for dma_buf_io_init_map().

---
 drivers/dma-buf/dma-buf-io.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/dma-buf/dma-buf-io.c +12 -0
index e432194a5dfc..f724936e223b 100644
@@ -43,6 +43,18 @@ static void dma_buf_io_kill_map(struct dma_buf_io_ctx *ctx)
 	dma_buf_io_map_release(map);
 }
 
+/**
+ * dma_buf_io_init_map - Initialise the map.
+ * @ctx:	[in]	dma-buf I/O context the map is created for
+ * @map:	[in]	dma-buf I/O map
+ * @sgt:	[in]	the backing scatter-gather table
+ *
+ * Importer's helper that initialises @map for the provided I/O context
+ * and scatter-gather table. The importer should call it once for each map
+ * on creation.
+ *
+ * Returns a map on success, or a negative errno code otherwise.
+ */
 int dma_buf_io_init_map(struct dma_buf_io_ctx *ctx, struct dma_buf_io_map *map,
 			struct sg_table *sgt)
 {
Signature · 1 line
2.54.0
#3 lore raw

Re: [PATCH 2/2] dma-buf-io: document dma_buf_io_init_map

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dma-buf: incorrect return value documentation in dma_buf_io_init_map() kerneldoc --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dma-buf: incorrect return value documentation in dma_buf_io_init_map() kerneldoc --

commit b6debb4c02ab1cee94fc3f78293f8425b78664d4
Author: Pavel Begunkov <[email protected]>

dma-buf-io: document dma_buf_io_init_map

This commit adds kerneldoc documentation for the dma_buf_io_init_map() function.

Quoted 9 lines
drivers/dma-buf/dma-buf-io.c +1 -0
index e432194a5dfc0..f724936e223b1 100644
@@ -43,6 +43,18 @@ static void dma_buf_io_kill_map(struct dma_buf_io_ctx *ctx)
 	dma_buf_io_map_release(map);
 }
 
+/**

drivers/dma-buf/dma-buf-io.c static void dma_buf_io_kill_map(struct dma_buf_io_ctx *ctx) · line 56

Quoted 10 lines
drivers/dma-buf/dma-buf-io.c +10 -0
+ * dma_buf_io_init_map - Initialise the map.
+ * @ctx:	[in]	dma-buf I/O context the map is created for
+ * @map:	[in]	dma-buf I/O map
+ * @sgt:	[in]	the backing scatter-gather table
+ *
+ * Importer's helper that initialises @map for the provided I/O context
+ * and scatter-gather table. The importer should call it once for each map
+ * on creation.
+ *
+ * Returns a map on success, or a negative errno code otherwise.

[Severity: Low]
This isn't a bug, but the kerneldoc states this function returns a map, while the actual implementation returns an int (0 on success) and modifies the map argument in place.

Could this be updated to accurately reflect the return value and use the standard "Return:" tag format expected by automated kerneldoc tools?

Quoted 4 lines
drivers/dma-buf/dma-buf-io.c +1 -0
+ */
 int dma_buf_io_init_map(struct dma_buf_io_ctx *ctx, struct dma_buf_io_map *map,
 			struct sg_table *sgt)
 {
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#4 lore raw

Re: [PATCH 2/2] dma-buf-io: document dma_buf_io_init_map

Quoted 20 lines · On 10/16/26 10:41, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dma-buf: incorrect return value documentation in dma_buf_io_init_map() kerneldoc --

commit b6debb4c02ab1cee94fc3f78293f8425b78664d4
Author: Pavel Begunkov <[email protected]>

dma-buf-io: document dma_buf_io_init_map

This commit adds kerneldoc documentation for the dma_buf_io_init_map() function.

Quoted 8 lines
drivers/dma-buf/dma-buf-io.c +0 -0
index e432194a5dfc0..f724936e223b1 100644
@@ -43,6 +43,18 @@ static void dma_buf_io_kill_map(struct dma_buf_io_ctx *ctx)
  	dma_buf_io_map_release(map);
  }
 
Quoted 16 lines

drivers/dma-buf/dma-buf-io.c static void dma_buf_io_kill_map(struct dma_buf_io_ctx *ctx) · line 56

Quoted 11 lines
drivers/dma-buf/dma-buf-io.c +11 -0
+/**
+ * dma_buf_io_init_map - Initialise the map.
+ * @ctx:	[in]	dma-buf I/O context the map is created for
+ * @map:	[in]	dma-buf I/O map
+ * @sgt:	[in]	the backing scatter-gather table
+ *
+ * Importer's helper that initialises @map for the provided I/O context
+ * and scatter-gather table. The importer should call it once for each map
+ * on creation.
+ *
+ * Returns a map on success, or a negative errno code otherwise.

[Severity: Low]
This isn't a bug, but the kerneldoc states this function returns a map, while the actual implementation returns an int (0 on success) and modifies the map argument in place.

Slipped through indeed.

Quoted 8 lines

Could this be updated to accurately reflect the return value and use the standard "Return:" tag format expected by automated kerneldoc tools?

Quoted 4 lines
drivers/dma-buf/dma-buf-io.c +1 -0
+ */
  int dma_buf_io_init_map(struct dma_buf_io_ctx *ctx, struct dma_buf_io_map *map,
  			struct sg_table *sgt)
  {
Signature · 1 line
Pavel Begunkov