diff mbox series

[15/49] drm/ttm: make some inline helper functions for cleanup paths.

Message ID 20200731040520.3701599-16-airlied@gmail.com (mailing list archive)
State New, archived
Headers show
Series ttm mem manager refactoring. | expand

Commit Message

Dave Airlie July 31, 2020, 4:04 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

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

Comments

Christian König July 31, 2020, 1:07 p.m. UTC | #1
Am 31.07.20 um 06:04 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    |  6 ++----
>   include/drm/ttm/ttm_bo_driver.h | 12 ++++++++++++
>   2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 84e399395e4f..f584e5e94383 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1462,8 +1462,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_bo_disable_mm(man);
>   
>   	ret = 0;
>   	if (mem_type > 0) {
> @@ -1476,8 +1475,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_bo_man_cleanup(man);
>   
>   	return ret;
>   }
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index d0f1a6cdfba7..92bb54cce633 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -671,6 +671,18 @@ static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man)
>   	man->use_type = true;
>   }
>   
> +static inline void ttm_bo_disable_mm(struct ttm_mem_type_manager *man)
> +{
> +	man->has_type = false;
> +	man->use_type = false;
> +}
> +
> +static inline void ttm_bo_man_cleanup(struct ttm_mem_type_manager *man)
> +{
> +	dma_fence_put(man->move);
> +	man->move = NULL;
> +}
> +

What's the value in making those inline? This is not performance 
critical at all.

Christian.

>   /*
>    * ttm_bo_util.c
>    */
Dave Airlie Aug. 4, 2020, 2:28 a.m. UTC | #2
On Fri, 31 Jul 2020 at 23:07, Christian König <christian.koenig@amd.com> wrote:
>
> Am 31.07.20 um 06:04 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c    |  6 ++----
> >   include/drm/ttm/ttm_bo_driver.h | 12 ++++++++++++
> >   2 files changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 84e399395e4f..f584e5e94383 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1462,8 +1462,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_bo_disable_mm(man);
> >
> >       ret = 0;
> >       if (mem_type > 0) {
> > @@ -1476,8 +1475,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_bo_man_cleanup(man);
> >
> >       return ret;
> >   }
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index d0f1a6cdfba7..92bb54cce633 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -671,6 +671,18 @@ static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man)
> >       man->use_type = true;
> >   }
> >
> > +static inline void ttm_bo_disable_mm(struct ttm_mem_type_manager *man)
> > +{
> > +     man->has_type = false;
> > +     man->use_type = false;
> > +}
> > +
> > +static inline void ttm_bo_man_cleanup(struct ttm_mem_type_manager *man)
> > +{
> > +     dma_fence_put(man->move);
> > +     man->move = NULL;
> > +}
> > +
>
> What's the value in making those inline? This is not performance
> critical at all.
>

Not for performance, but they were too trivial to bother putting in
real functions, if there was more going on I'd probably have put them
into functions, but setting two bits, and putting a fence didn't seem
worth adding function call overhead where there was none before.

Dave.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 84e399395e4f..f584e5e94383 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1462,8 +1462,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_bo_disable_mm(man);
 
 	ret = 0;
 	if (mem_type > 0) {
@@ -1476,8 +1475,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_bo_man_cleanup(man);
 
 	return ret;
 }
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index d0f1a6cdfba7..92bb54cce633 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -671,6 +671,18 @@  static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man)
 	man->use_type = true;
 }
 
+static inline void ttm_bo_disable_mm(struct ttm_mem_type_manager *man)
+{
+	man->has_type = false;
+	man->use_type = false;
+}
+
+static inline void ttm_bo_man_cleanup(struct ttm_mem_type_manager *man)
+{
+	dma_fence_put(man->move);
+	man->move = NULL;
+}
+
 /*
  * ttm_bo_util.c
  */