[v2 16/31] drm/xe/svm: Get xe memory region from page
Matthew Brost
matthew.brost at intel.com
Wed Apr 10 21:38:03 UTC 2024
On Tue, Apr 09, 2024 at 04:17:27PM -0400, Oak Zeng wrote:
> For gpu vram page, we now have a struct page backing of
> it. struct page's pgmap points to xe_memory_region's
> pagemap. This allow us to retrieve xe_memory_region
> from struct page.
>
> v1: move the function to xe_svm.h
>
> Signed-off-by: Oak Zeng <oak.zeng at intel.com>
> ---
> drivers/gpu/drm/xe/xe_svm.h | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_svm.h b/drivers/gpu/drm/xe/xe_svm.h
> index 8a34429eb674..624c1581f8ba 100644
> --- a/drivers/gpu/drm/xe/xe_svm.h
> +++ b/drivers/gpu/drm/xe/xe_svm.h
See my comments about location in previous patch and also if this can be
a private function if implementation is in 1 *.c file.
> @@ -6,6 +6,7 @@
> #ifndef __XE_SVM_H
> #define __XE_SVM_H
>
> +#include <linux/mm_types.h>
> #include "xe_device_types.h"
> #include "xe_device.h"
> #include "xe_assert.h"
> @@ -35,4 +36,14 @@ static inline u64 xe_mem_region_pfn_to_dpa(struct xe_mem_region *mr, u64 pfn)
> int xe_devm_add(struct xe_tile *tile, struct xe_mem_region *mr);
> void xe_devm_remove(struct xe_tile *tile, struct xe_mem_region *mr);
>
> +/**
> + * xe_page_to_mem_region() - Get a page's memory region
> + *
> + * @page: a struct page pointer pointing to a page in vram memory region
> + */
> +static inline struct xe_mem_region *xe_page_to_mem_region(struct page *page)
> +{
> + return container_of(page->pgmap, struct xe_mem_region, pagemap);
> +}
If the previous patch is xe_mem_region_page_to_dpa and want very robust
code we could add an assert to that function.
xe_assert(xe, mr == xe_page_to_mem_region(page));
Matt
> +
> #endif
> --
> 2.26.3
>
More information about the Intel-xe
mailing list