* [Intel-xe] [PATCH] drm/xe: use variable instead of multiple function calls
@ 2023-10-30 19:38 Dani Liberman
2023-10-31 0:55 ` Matthew Brost
2023-10-31 6:13 ` Ville Syrjälä
0 siblings, 2 replies; 3+ messages in thread
From: Dani Liberman @ 2023-10-30 19:38 UTC (permalink / raw)
To: intel-xe
Also changed to positive logic which is more readable.
Signed-off-by: Dani Liberman <dliberman@habana.ai>
---
drivers/gpu/drm/xe/xe_exec.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
index 28e84a0bbeb0..2de6c2c05078 100644
--- a/drivers/gpu/drm/xe/xe_exec.c
+++ b/drivers/gpu/drm/xe/xe_exec.c
@@ -145,7 +145,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
struct xe_sched_job *job;
struct dma_fence *rebind_fence;
struct xe_vm *vm;
- bool write_locked;
+ bool write_locked, vm_with_dma_fences;
ktime_t end = 0;
int err = 0;
@@ -196,8 +196,9 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
}
}
+ vm_with_dma_fences = !xe_vm_no_dma_fences(vm);
retry:
- if (!xe_vm_no_dma_fences(vm) && xe_vm_userptr_check_repin(vm)) {
+ if (vm_with_dma_fences && xe_vm_userptr_check_repin(vm)) {
err = down_write_killable(&vm->lock);
write_locked = true;
} else {
@@ -279,7 +280,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
}
/* Wait behind munmap style rebinds */
- if (!xe_vm_no_dma_fences(vm)) {
+ if (vm_with_dma_fences) {
err = drm_sched_job_add_resv_dependencies(&job->drm,
&vm->resv,
DMA_RESV_USAGE_KERNEL);
@@ -292,7 +293,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
if (err)
goto err_put_job;
- if (!xe_vm_no_dma_fences(vm)) {
+ if (vm_with_dma_fences) {
err = down_read_interruptible(&vm->userptr.notifier_lock);
if (err)
goto err_put_job;
@@ -307,7 +308,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
* the job and let the DRM scheduler / backend clean up the job.
*/
xe_sched_job_arm(job);
- if (!xe_vm_no_dma_fences(vm)) {
+ if (vm_with_dma_fences) {
/* Block userptr invalidations / BO eviction */
dma_resv_add_fence(&vm->resv,
&job->drm.s_fence->finished,
@@ -330,14 +331,14 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
xe_sched_job_push(job);
xe_vm_reactivate_rebind(vm);
- if (!err && !xe_vm_no_dma_fences(vm)) {
+ if (!err && vm_with_dma_fences) {
spin_lock(&xe->ttm.lru_lock);
ttm_lru_bulk_move_tail(&vm->lru_bulk_move);
spin_unlock(&xe->ttm.lru_lock);
}
err_repin:
- if (!xe_vm_no_dma_fences(vm))
+ if (vm_with_dma_fences)
up_read(&vm->userptr.notifier_lock);
err_put_job:
if (err)
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Intel-xe] [PATCH] drm/xe: use variable instead of multiple function calls
2023-10-30 19:38 [Intel-xe] [PATCH] drm/xe: use variable instead of multiple function calls Dani Liberman
@ 2023-10-31 0:55 ` Matthew Brost
2023-10-31 6:13 ` Ville Syrjälä
1 sibling, 0 replies; 3+ messages in thread
From: Matthew Brost @ 2023-10-31 0:55 UTC (permalink / raw)
To: Dani Liberman; +Cc: intel-xe
On Mon, Oct 30, 2023 at 09:38:50PM +0200, Dani Liberman wrote:
> Also changed to positive logic which is more readable.
>
> Signed-off-by: Dani Liberman <dliberman@habana.ai>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_exec.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
> index 28e84a0bbeb0..2de6c2c05078 100644
> --- a/drivers/gpu/drm/xe/xe_exec.c
> +++ b/drivers/gpu/drm/xe/xe_exec.c
> @@ -145,7 +145,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> struct xe_sched_job *job;
> struct dma_fence *rebind_fence;
> struct xe_vm *vm;
> - bool write_locked;
> + bool write_locked, vm_with_dma_fences;
> ktime_t end = 0;
> int err = 0;
>
> @@ -196,8 +196,9 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> }
> }
>
> + vm_with_dma_fences = !xe_vm_no_dma_fences(vm);
> retry:
> - if (!xe_vm_no_dma_fences(vm) && xe_vm_userptr_check_repin(vm)) {
> + if (vm_with_dma_fences && xe_vm_userptr_check_repin(vm)) {
> err = down_write_killable(&vm->lock);
> write_locked = true;
> } else {
> @@ -279,7 +280,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> }
>
> /* Wait behind munmap style rebinds */
> - if (!xe_vm_no_dma_fences(vm)) {
> + if (vm_with_dma_fences) {
> err = drm_sched_job_add_resv_dependencies(&job->drm,
> &vm->resv,
> DMA_RESV_USAGE_KERNEL);
> @@ -292,7 +293,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> if (err)
> goto err_put_job;
>
> - if (!xe_vm_no_dma_fences(vm)) {
> + if (vm_with_dma_fences) {
> err = down_read_interruptible(&vm->userptr.notifier_lock);
> if (err)
> goto err_put_job;
> @@ -307,7 +308,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> * the job and let the DRM scheduler / backend clean up the job.
> */
> xe_sched_job_arm(job);
> - if (!xe_vm_no_dma_fences(vm)) {
> + if (vm_with_dma_fences) {
> /* Block userptr invalidations / BO eviction */
> dma_resv_add_fence(&vm->resv,
> &job->drm.s_fence->finished,
> @@ -330,14 +331,14 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> xe_sched_job_push(job);
> xe_vm_reactivate_rebind(vm);
>
> - if (!err && !xe_vm_no_dma_fences(vm)) {
> + if (!err && vm_with_dma_fences) {
> spin_lock(&xe->ttm.lru_lock);
> ttm_lru_bulk_move_tail(&vm->lru_bulk_move);
> spin_unlock(&xe->ttm.lru_lock);
> }
>
> err_repin:
> - if (!xe_vm_no_dma_fences(vm))
> + if (vm_with_dma_fences)
> up_read(&vm->userptr.notifier_lock);
> err_put_job:
> if (err)
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-xe] [PATCH] drm/xe: use variable instead of multiple function calls
2023-10-30 19:38 [Intel-xe] [PATCH] drm/xe: use variable instead of multiple function calls Dani Liberman
2023-10-31 0:55 ` Matthew Brost
@ 2023-10-31 6:13 ` Ville Syrjälä
1 sibling, 0 replies; 3+ messages in thread
From: Ville Syrjälä @ 2023-10-31 6:13 UTC (permalink / raw)
To: Dani Liberman; +Cc: intel-xe
On Mon, Oct 30, 2023 at 09:38:50PM +0200, Dani Liberman wrote:
> Also changed to positive logic which is more readable.
Please write proper commit messages.
>
> Signed-off-by: Dani Liberman <dliberman@habana.ai>
> ---
> drivers/gpu/drm/xe/xe_exec.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
> index 28e84a0bbeb0..2de6c2c05078 100644
> --- a/drivers/gpu/drm/xe/xe_exec.c
> +++ b/drivers/gpu/drm/xe/xe_exec.c
> @@ -145,7 +145,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> struct xe_sched_job *job;
> struct dma_fence *rebind_fence;
> struct xe_vm *vm;
> - bool write_locked;
> + bool write_locked, vm_with_dma_fences;
> ktime_t end = 0;
> int err = 0;
>
> @@ -196,8 +196,9 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> }
> }
>
> + vm_with_dma_fences = !xe_vm_no_dma_fences(vm);
> retry:
> - if (!xe_vm_no_dma_fences(vm) && xe_vm_userptr_check_repin(vm)) {
> + if (vm_with_dma_fences && xe_vm_userptr_check_repin(vm)) {
> err = down_write_killable(&vm->lock);
> write_locked = true;
> } else {
> @@ -279,7 +280,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> }
>
> /* Wait behind munmap style rebinds */
> - if (!xe_vm_no_dma_fences(vm)) {
> + if (vm_with_dma_fences) {
> err = drm_sched_job_add_resv_dependencies(&job->drm,
> &vm->resv,
> DMA_RESV_USAGE_KERNEL);
> @@ -292,7 +293,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> if (err)
> goto err_put_job;
>
> - if (!xe_vm_no_dma_fences(vm)) {
> + if (vm_with_dma_fences) {
> err = down_read_interruptible(&vm->userptr.notifier_lock);
> if (err)
> goto err_put_job;
> @@ -307,7 +308,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> * the job and let the DRM scheduler / backend clean up the job.
> */
> xe_sched_job_arm(job);
> - if (!xe_vm_no_dma_fences(vm)) {
> + if (vm_with_dma_fences) {
> /* Block userptr invalidations / BO eviction */
> dma_resv_add_fence(&vm->resv,
> &job->drm.s_fence->finished,
> @@ -330,14 +331,14 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> xe_sched_job_push(job);
> xe_vm_reactivate_rebind(vm);
>
> - if (!err && !xe_vm_no_dma_fences(vm)) {
> + if (!err && vm_with_dma_fences) {
> spin_lock(&xe->ttm.lru_lock);
> ttm_lru_bulk_move_tail(&vm->lru_bulk_move);
> spin_unlock(&xe->ttm.lru_lock);
> }
>
> err_repin:
> - if (!xe_vm_no_dma_fences(vm))
> + if (vm_with_dma_fences)
> up_read(&vm->userptr.notifier_lock);
> err_put_job:
> if (err)
> --
> 2.34.1
--
Ville Syrjälä
Intel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-31 6:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30 19:38 [Intel-xe] [PATCH] drm/xe: use variable instead of multiple function calls Dani Liberman
2023-10-31 0:55 ` Matthew Brost
2023-10-31 6:13 ` Ville Syrjälä
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox