[25/59] drm/ttm: make some inline helper functions for cleanup paths. (v2)
diff mbox series

Message ID 20200804025632.3868079-26-airlied@gmail.com
State New
Headers show
Series
  • ttm misc cleanups, mem refactoring, rename objects. (v2)
Related show

Commit Message

Dave Airlie Aug. 4, 2020, 2:55 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

The disable path is just temporary for now, it will be dropped once has_type
is gone in a later patch.

v2: add docs.
rename to ttm_mem_type_manager namespace

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    |  6 ++----
 include/drm/ttm/ttm_bo_driver.h | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 4 deletions(-)

Comments

Christian König Aug. 4, 2020, 11:18 a.m. UTC | #1
Am 04.08.20 um 04:55 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> The disable path is just temporary for now, it will be dropped once has_type
> is gone in a later patch.
>
> v2: add docs.
> rename to ttm_mem_type_manager namespace
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    |  6 ++----
>   include/drm/ttm/ttm_bo_driver.h | 26 ++++++++++++++++++++++++++
>   2 files changed, 28 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index af1b1c3f6ed2..127a0b62bf98 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1468,8 +1468,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   		return ret;
>   	}
>   
> -	man->use_type = false;
> -	man->has_type = false;
> +	ttm_mem_type_manager_disable(man);
>   
>   	ret = 0;
>   	if (mem_type > 0) {
> @@ -1482,8 +1481,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
>   		ret = (*man->func->takedown)(man);
>   	}
>   
> -	dma_fence_put(man->move);
> -	man->move = NULL;
> +	ttm_mem_type_manager_cleanup(man);
>   
>   	return ret;
>   }
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 548c27294c64..41bfa514c29d 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -680,6 +680,32 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
>   	man->use_type = used;
>   }
>   
> +/**
> + * ttm_mem_type_manager_disable.
> + *
> + * @man: A memory manager object.
> + *
> + * Indicate the manager is not to be used and deregistered. (temporary during rework).
> + */
> +static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man)
> +{
> +	man->has_type = false;
> +	man->use_type = false;
> +}
> +
> +/**
> + * ttm_mem_type_manager_cleanup
> + *
> + * @man: A memory manager object.
> + *
> + * Cleanup the move fences from the memory manager object.
> + */
> +static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man)
> +{
> +	dma_fence_put(man->move);
> +	man->move = NULL;
> +}
> +
>   /*
>    * ttm_bo_util.c
>    */
Ben Skeggs Aug. 5, 2020, 5:42 a.m. UTC | #2
On Tue, 4 Aug 2020 at 21:18, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:55 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > The disable path is just temporary for now, it will be dropped once has_type
> > is gone in a later patch.
> >
> > v2: add docs.
> > rename to ttm_mem_type_manager namespace
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c    |  6 ++----
> >   include/drm/ttm/ttm_bo_driver.h | 26 ++++++++++++++++++++++++++
> >   2 files changed, 28 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index af1b1c3f6ed2..127a0b62bf98 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1468,8 +1468,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >               return ret;
> >       }
> >
> > -     man->use_type = false;
> > -     man->has_type = false;
> > +     ttm_mem_type_manager_disable(man);
> >
> >       ret = 0;
> >       if (mem_type > 0) {
> > @@ -1482,8 +1481,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
> >               ret = (*man->func->takedown)(man);
> >       }
> >
> > -     dma_fence_put(man->move);
> > -     man->move = NULL;
> > +     ttm_mem_type_manager_cleanup(man);
> >
> >       return ret;
> >   }
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index 548c27294c64..41bfa514c29d 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -680,6 +680,32 @@ static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
> >       man->use_type = used;
> >   }
> >
> > +/**
> > + * ttm_mem_type_manager_disable.
> > + *
> > + * @man: A memory manager object.
> > + *
> > + * Indicate the manager is not to be used and deregistered. (temporary during rework).
> > + */
> > +static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man)
> > +{
> > +     man->has_type = false;
> > +     man->use_type = false;
> > +}
> > +
> > +/**
> > + * ttm_mem_type_manager_cleanup
> > + *
> > + * @man: A memory manager object.
> > + *
> > + * Cleanup the move fences from the memory manager object.
> > + */
> > +static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man)
> > +{
> > +     dma_fence_put(man->move);
> > +     man->move = NULL;
> > +}
> > +
> >   /*
> >    * ttm_bo_util.c
> >    */
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox series

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index af1b1c3f6ed2..127a0b62bf98 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1468,8 +1468,7 @@  int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 		return ret;
 	}
 
-	man->use_type = false;
-	man->has_type = false;
+	ttm_mem_type_manager_disable(man);
 
 	ret = 0;
 	if (mem_type > 0) {
@@ -1482,8 +1481,7 @@  int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
 		ret = (*man->func->takedown)(man);
 	}
 
-	dma_fence_put(man->move);
-	man->move = NULL;
+	ttm_mem_type_manager_cleanup(man);
 
 	return ret;
 }
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 548c27294c64..41bfa514c29d 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -680,6 +680,32 @@  static inline void ttm_mem_type_manager_set_used(struct ttm_mem_type_manager *ma
 	man->use_type = used;
 }
 
+/**
+ * ttm_mem_type_manager_disable.
+ *
+ * @man: A memory manager object.
+ *
+ * Indicate the manager is not to be used and deregistered. (temporary during rework).
+ */
+static inline void ttm_mem_type_manager_disable(struct ttm_mem_type_manager *man)
+{
+	man->has_type = false;
+	man->use_type = false;
+}
+
+/**
+ * ttm_mem_type_manager_cleanup
+ *
+ * @man: A memory manager object.
+ *
+ * Cleanup the move fences from the memory manager object.
+ */
+static inline void ttm_mem_type_manager_cleanup(struct ttm_mem_type_manager *man)
+{
+	dma_fence_put(man->move);
+	man->move = NULL;
+}
+
 /*
  * ttm_bo_util.c
  */