]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/nouveau: Implement intersect/compatible functions
authorArunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Sat, 20 Aug 2022 07:33:03 +0000 (00:33 -0700)
committerChristian König <christian.koenig@amd.com>
Mon, 22 Aug 2022 13:36:11 +0000 (15:36 +0200)
Implemented a new intersect and compatible callback function
fetching the start offset from struct ttm_resource.

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220820073304.178444-5-Arunpravin.PaneerSelvam@amd.com
drivers/gpu/drm/nouveau/nouveau_mem.c
drivers/gpu/drm/nouveau/nouveau_mem.h
drivers/gpu/drm/nouveau/nouveau_ttm.c

index 2e517cdc24c9c1be93311b988a8d820188beaba9..76f8edefa63787520deca92e5b952075de0c05d7 100644 (file)
@@ -187,3 +187,32 @@ nouveau_mem_new(struct nouveau_cli *cli, u8 kind, u8 comp,
        *res = &mem->base;
        return 0;
 }
+
+bool
+nouveau_mem_intersects(struct ttm_resource *res,
+                      const struct ttm_place *place,
+                      size_t size)
+{
+       u32 num_pages = PFN_UP(size);
+
+       /* Don't evict BOs outside of the requested placement range */
+       if (place->fpfn >= (res->start + num_pages) ||
+           (place->lpfn && place->lpfn <= res->start))
+               return false;
+
+       return true;
+}
+
+bool
+nouveau_mem_compatible(struct ttm_resource *res,
+                      const struct ttm_place *place,
+                      size_t size)
+{
+       u32 num_pages = PFN_UP(size);
+
+       if (res->start < place->fpfn ||
+           (place->lpfn && (res->start + num_pages) > place->lpfn))
+               return false;
+
+       return true;
+}
index 325551eba5cd44fb2082d593c85ad60109bde885..1ee6cdb9ad9bce30db5ce33d4da00f4499024252 100644 (file)
@@ -25,6 +25,12 @@ int nouveau_mem_new(struct nouveau_cli *, u8 kind, u8 comp,
                    struct ttm_resource **);
 void nouveau_mem_del(struct ttm_resource_manager *man,
                     struct ttm_resource *);
+bool nouveau_mem_intersects(struct ttm_resource *res,
+                           const struct ttm_place *place,
+                           size_t size);
+bool nouveau_mem_compatible(struct ttm_resource *res,
+                           const struct ttm_place *place,
+                           size_t size);
 int nouveau_mem_vram(struct ttm_resource *, bool contig, u8 page);
 int nouveau_mem_host(struct ttm_resource *, struct ttm_tt *);
 void nouveau_mem_fini(struct nouveau_mem *);
index 85f1f5a0fe5dfe8e5553950ecd3c353e46183b0e..9602c30928f20c3505d73cc77cdb4c6a3edff3a1 100644 (file)
@@ -42,6 +42,24 @@ nouveau_manager_del(struct ttm_resource_manager *man,
        nouveau_mem_del(man, reg);
 }
 
+static bool
+nouveau_manager_intersects(struct ttm_resource_manager *man,
+                          struct ttm_resource *res,
+                          const struct ttm_place *place,
+                          size_t size)
+{
+       return nouveau_mem_intersects(res, place, size);
+}
+
+static bool
+nouveau_manager_compatible(struct ttm_resource_manager *man,
+                          struct ttm_resource *res,
+                          const struct ttm_place *place,
+                          size_t size)
+{
+       return nouveau_mem_compatible(res, place, size);
+}
+
 static int
 nouveau_vram_manager_new(struct ttm_resource_manager *man,
                         struct ttm_buffer_object *bo,
@@ -73,6 +91,8 @@ nouveau_vram_manager_new(struct ttm_resource_manager *man,
 const struct ttm_resource_manager_func nouveau_vram_manager = {
        .alloc = nouveau_vram_manager_new,
        .free = nouveau_manager_del,
+       .intersects = nouveau_manager_intersects,
+       .compatible = nouveau_manager_compatible,
 };
 
 static int
@@ -97,6 +117,8 @@ nouveau_gart_manager_new(struct ttm_resource_manager *man,
 const struct ttm_resource_manager_func nouveau_gart_manager = {
        .alloc = nouveau_gart_manager_new,
        .free = nouveau_manager_del,
+       .intersects = nouveau_manager_intersects,
+       .compatible = nouveau_manager_compatible,
 };
 
 static int
@@ -130,6 +152,8 @@ nv04_gart_manager_new(struct ttm_resource_manager *man,
 const struct ttm_resource_manager_func nv04_gart_manager = {
        .alloc = nv04_gart_manager_new,
        .free = nouveau_manager_del,
+       .intersects = nouveau_manager_intersects,
+       .compatible = nouveau_manager_compatible,
 };
 
 static int