Message ID | 20231031151257.90350-3-sarah.walker@imgtec.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Imagination Technologies PowerVR DRM driver | expand |
On 10/31/23 16:12, Sarah Walker wrote: > From: Donald Robson <donald.robson@imgtec.com> > > Determining the start and range of the unmap stage of a remap op is a > common piece of code currently implemented by multiple drivers. Add a > helper for this. > > Changes since v7: > - Renamed helper to drm_gpuva_op_remap_to_unmap_range() > - Improved documentation > > Changes since v6: > - Remove use of __always_inline > > Signed-off-by: Donald Robson <donald.robson@imgtec.com> > Signed-off-by: Sarah Walker <sarah.walker@imgtec.com> Reviewed-by: Danilo Krummrich <dakr@redhat.com> Want me to apply the patch? > --- > include/drm/drm_gpuvm.h | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h > index c7ed6bf441d4..c64585dc4e8e 100644 > --- a/include/drm/drm_gpuvm.h > +++ b/include/drm/drm_gpuvm.h > @@ -702,4 +702,32 @@ void drm_gpuva_remap(struct drm_gpuva *prev, > > void drm_gpuva_unmap(struct drm_gpuva_op_unmap *op); > > +/** > + * drm_gpuva_op_remap_to_unmap_range() - Helper to get the start and range of > + * the unmap stage of a remap op. > + * @op: Remap op. > + * @start_addr: Output pointer for the start of the required unmap. > + * @range: Output pointer for the length of the required unmap. > + * > + * The given start address and range will be set such that they represent the > + * range of the address space that was previously covered by the mapping being > + * re-mapped, but is now empty. > + */ > +static inline void > +drm_gpuva_op_remap_to_unmap_range(const struct drm_gpuva_op_remap *op, > + u64 *start_addr, u64 *range) > +{ > + const u64 va_start = op->prev ? > + op->prev->va.addr + op->prev->va.range : > + op->unmap->va->va.addr; > + const u64 va_end = op->next ? > + op->next->va.addr : > + op->unmap->va->va.addr + op->unmap->va->va.range; > + > + if (start_addr) > + *start_addr = va_start; > + if (range) > + *range = va_end - va_start; > +} > + > #endif /* __DRM_GPUVM_H__ */
On Tue, 2023-11-14 at 17:42 +0100, Danilo Krummrich wrote: > *** CAUTION: This email originates from a source not known to Imagination Technologies. Think before you click a link or open an attachment *** > > On 10/31/23 16:12, Sarah Walker wrote: > > From: Donald Robson <donald.robson@imgtec.com> > > > > Determining the start and range of the unmap stage of a remap op is a > > common piece of code currently implemented by multiple drivers. Add a > > helper for this. > > > > Changes since v7: > > - Renamed helper to drm_gpuva_op_remap_to_unmap_range() > > - Improved documentation > > > > Changes since v6: > > - Remove use of __always_inline > > > > Signed-off-by: Donald Robson <donald.robson@imgtec.com> > > Signed-off-by: Sarah Walker <sarah.walker@imgtec.com> > > Reviewed-by: Danilo Krummrich <dakr@redhat.com> > > Want me to apply the patch? Yes please! Thanks again Danilo. > > > --- > > include/drm/drm_gpuvm.h | 28 ++++++++++++++++++++++++++++ > > 1 file changed, 28 insertions(+) > > > > diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h > > index c7ed6bf441d4..c64585dc4e8e 100644 > > --- a/include/drm/drm_gpuvm.h > > +++ b/include/drm/drm_gpuvm.h > > @@ -702,4 +702,32 @@ void drm_gpuva_remap(struct drm_gpuva *prev, > > > > void drm_gpuva_unmap(struct drm_gpuva_op_unmap *op); > > > > +/** > > + * drm_gpuva_op_remap_to_unmap_range() - Helper to get the start and range of > > + * the unmap stage of a remap op. > > + * @op: Remap op. > > + * @start_addr: Output pointer for the start of the required unmap. > > + * @range: Output pointer for the length of the required unmap. > > + * > > + * The given start address and range will be set such that they represent the > > + * range of the address space that was previously covered by the mapping being > > + * re-mapped, but is now empty. > > + */ > > +static inline void > > +drm_gpuva_op_remap_to_unmap_range(const struct drm_gpuva_op_remap *op, > > + u64 *start_addr, u64 *range) > > +{ > > + const u64 va_start = op->prev ? > > + op->prev->va.addr + op->prev->va.range : > > + op->unmap->va->va.addr; > > + const u64 va_end = op->next ? > > + op->next->va.addr : > > + op->unmap->va->va.addr + op->unmap->va->va.range; > > + > > + if (start_addr) > > + *start_addr = va_start; > > + if (range) > > + *range = va_end - va_start; > > +} > > + > > #endif /* __DRM_GPUVM_H__ */
diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h index c7ed6bf441d4..c64585dc4e8e 100644 --- a/include/drm/drm_gpuvm.h +++ b/include/drm/drm_gpuvm.h @@ -702,4 +702,32 @@ void drm_gpuva_remap(struct drm_gpuva *prev, void drm_gpuva_unmap(struct drm_gpuva_op_unmap *op); +/** + * drm_gpuva_op_remap_to_unmap_range() - Helper to get the start and range of + * the unmap stage of a remap op. + * @op: Remap op. + * @start_addr: Output pointer for the start of the required unmap. + * @range: Output pointer for the length of the required unmap. + * + * The given start address and range will be set such that they represent the + * range of the address space that was previously covered by the mapping being + * re-mapped, but is now empty. + */ +static inline void +drm_gpuva_op_remap_to_unmap_range(const struct drm_gpuva_op_remap *op, + u64 *start_addr, u64 *range) +{ + const u64 va_start = op->prev ? + op->prev->va.addr + op->prev->va.range : + op->unmap->va->va.addr; + const u64 va_end = op->next ? + op->next->va.addr : + op->unmap->va->va.addr + op->unmap->va->va.range; + + if (start_addr) + *start_addr = va_start; + if (range) + *range = va_end - va_start; +} + #endif /* __DRM_GPUVM_H__ */