Skip to contentSkip to conversation

Patch "drm/ttm: Add ttm_bo_access" has been added to the 6.12-stable tree

DISCUSSION Christian König 2 participants 3 messages Feb 3, 2025 1 message not in the archive Stable branch

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Am 02.02.25 um 05:33 schrieb Sasha Levin:

Quoted 6 lines

This is a note to let you know that I've just added the patch titled

drm/ttm: Add ttm_bo_access

to the 6.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

This isn't a bug fix but a new feature and therefore shouldn't be backported.

Regards,
Christian.

Quoted 121 lines

The filename of the patch is:
drm-ttm-add-ttm_bo_access.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

commit 73b922f15552bb5b47cbcca4b4d2b131b89b786d

Author: Matthew Brost <[email protected]>
Date:   Tue Nov 26 09:46:09 2024 -0800

drm/ttm: Add ttm_bo_access

[ Upstream commit 7d08df5d0bd3d12d14dcec773fcddbe3eed3a8e8 ]

Non-contiguous VRAM cannot easily be mapped in TTM nor can non-visible VRAM easily be accessed. Add ttm_bo_access, which is similar to ttm_bo_vm_access, to access such memory.

v4:
- Fix checkpatch warnings (CI)
v5:
- Fix checkpatch warnings (CI)
v6:
- Fix kernel doc (Auld)
v7:
- Move ttm_bo_access to ttm_bo_vm.c (Christian)

Stable-dep-of: 5f7bec831f1f ("drm/xe: Use ttm_bo_access in xe_vm_snapshot_capture_delayed")

drivers/gpu/drm/ttm/ttm_bo_vm.c +32 -8
index 4212b8c91dd42..17667ab31ad4c 100644
@@ -405,13 +405,25 @@ static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo,
  	return len;
  }
 
-int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
-		     void *buf, int len, int write)
+/**
+ * ttm_bo_access - Helper to access a buffer object
+ *
+ * @bo: ttm buffer object
+ * @offset: access offset into buffer object
+ * @buf: pointer to caller memory to read into or write from
+ * @len: length of access
+ * @write: write access
+ *
+ * Utility function to access a buffer object. Useful when buffer object cannot
+ * be easily mapped (non-contiguous, non-visible, etc...). Should not directly
+ * be exported to user space via a peak / poke interface.
+ *
+ * Returns:
+ * @len if successful, negative error code on failure.
+ */
+int ttm_bo_access(struct ttm_buffer_object *bo, unsigned long offset,
+		  void *buf, int len, int write)
  {
-	struct ttm_buffer_object *bo = vma->vm_private_data;
-	unsigned long offset = (addr) - vma->vm_start +
-		((vma->vm_pgoff - drm_vma_node_start(&bo->base.vma_node))
-		 << PAGE_SHIFT);
  	int ret;
 
  	if (len < 1 || (offset + len) > bo->base.size)
@@ -429,8 +441,8 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
  		break;
  	default:
  		if (bo->bdev->funcs->access_memory)
-			ret = bo->bdev->funcs->access_memory(
-				bo, offset, buf, len, write);
+			ret = bo->bdev->funcs->access_memory
+				(bo, offset, buf, len, write);
  		else
  			ret = -EIO;
  	}
@@ -439,6 +451,18 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
 
  	return ret;
  }
+EXPORT_SYMBOL(ttm_bo_access);
+
+int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
+		     void *buf, int len, int write)
+{
+	struct ttm_buffer_object *bo = vma->vm_private_data;
+	unsigned long offset = (addr) - vma->vm_start +
+		((vma->vm_pgoff - drm_vma_node_start(&bo->base.vma_node))
+		 << PAGE_SHIFT);
+
+	return ttm_bo_access(bo, offset, buf, len, write);
+}
  EXPORT_SYMBOL(ttm_bo_vm_access);
 
  static const struct vm_operations_struct ttm_bo_vm_ops = {
include/drm/ttm/ttm_bo.h +2 -0
index 7b56d1ca36d75..e383dee82001e 100644
@@ -421,6 +421,8 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo);
  int ttm_bo_evict_first(struct ttm_device *bdev,
  		       struct ttm_resource_manager *man,
  		       struct ttm_operation_ctx *ctx);
+int ttm_bo_access(struct ttm_buffer_object *bo, unsigned long offset,
+		  void *buf, int len, int write);
  vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,
  			     struct vm_fault *vmf);
  vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
maintainer
#2 lore raw
Quoted 9 lines · Christian König

Am 02.02.25 um 05:33 schrieb Sasha Levin:

Quoted 6 lines

This is a note to let you know that I've just added the patch titled

drm/ttm: Add ttm_bo_access

to the 6.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

This isn't a bug fix but a new feature and therefore shouldn't be backported.

Right, it was added as a dependency for:

Quoted 1 line
Quoted 1 line

Stable-dep-of: 5f7bec831f1f ("drm/xe: Use ttm_bo_access in xe_vm_snapshot_capture_delayed")

But since 5f7bec831f1f is going to be dropped, I'll drop this commit too.

Signature · 2 lines
Thanks,
Sasha
#3 lore raw

Am 03.02.25 um 13:40 schrieb Sasha Levin:

Quoted 14 lines · Christian König
Quoted 9 lines

Am 02.02.25 um 05:33 schrieb Sasha Levin:

Quoted 6 lines

This is a note to let you know that I've just added the patch titled

    drm/ttm: Add ttm_bo_access

to the 6.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

This isn't a bug fix but a new feature and therefore shouldn't be backported.

Right, it was added as a dependency for:

Quoted 1 line
Quoted 1 line

    Stable-dep-of: 5f7bec831f1f ("drm/xe: Use ttm_bo_access in xe_vm_snapshot_capture_delayed")

Ah! Completely missed that line.

Quoted 3 lines

But since 5f7bec831f1f is going to be dropped, I'll drop this commit too.

Yeah, that is a good idea. All of this are new features and not bug fixes.

Thanks,
Christian.