2024-06-03 21:11:15

by Thorsten Blum

[permalink] [raw]
Subject: [PATCH] drm/xe/vm: Simplify if condition

The if condition !A || A && B can be simplified to !A || B.

Fixes the following Coccinelle/coccicheck warning reported by
excluded_middle.cocci:

WARNING !A || A && B is equivalent to !A || B

Compile-tested only.

Signed-off-by: Thorsten Blum <[email protected]>
---
drivers/gpu/drm/xe/xe_vm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 4aa3943e6f29..3137cbbaabde 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -85,8 +85,8 @@ static bool preempt_fences_waiting(struct xe_vm *vm)

list_for_each_entry(q, &vm->preempt.exec_queues, compute.link) {
if (!q->compute.pfence ||
- (q->compute.pfence && test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
- &q->compute.pfence->flags))) {
+ test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
+ &q->compute.pfence->flags)) {
return true;
}
}
--
2.39.2



2024-06-04 18:13:19

by Matthew Brost

[permalink] [raw]
Subject: Re: [PATCH] drm/xe/vm: Simplify if condition

On Mon, Jun 03, 2024 at 08:00:07PM +0200, Thorsten Blum wrote:
> The if condition !A || A && B can be simplified to !A || B.
>
> Fixes the following Coccinelle/coccicheck warning reported by
> excluded_middle.cocci:
>
> WARNING !A || A && B is equivalent to !A || B
>
> Compile-tested only.
>
> Signed-off-by: Thorsten Blum <[email protected]>

Reviewed-by: Matthew Brost <[email protected]>

Will get this merged once our CI system is working.

> ---
> drivers/gpu/drm/xe/xe_vm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index 4aa3943e6f29..3137cbbaabde 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -85,8 +85,8 @@ static bool preempt_fences_waiting(struct xe_vm *vm)
>
> list_for_each_entry(q, &vm->preempt.exec_queues, compute.link) {
> if (!q->compute.pfence ||
> - (q->compute.pfence && test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> - &q->compute.pfence->flags))) {
> + test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> + &q->compute.pfence->flags)) {
> return true;
> }
> }
> --
> 2.39.2
>

2024-06-05 16:38:16

by Matthew Brost

[permalink] [raw]
Subject: Re: [PATCH] drm/xe/vm: Simplify if condition

On Tue, Jun 04, 2024 at 06:06:22PM +0000, Matthew Brost wrote:
> On Mon, Jun 03, 2024 at 08:00:07PM +0200, Thorsten Blum wrote:
> > The if condition !A || A && B can be simplified to !A || B.
> >
> > Fixes the following Coccinelle/coccicheck warning reported by
> > excluded_middle.cocci:
> >
> > WARNING !A || A && B is equivalent to !A || B
> >
> > Compile-tested only.
> >
> > Signed-off-by: Thorsten Blum <[email protected]>
>
> Reviewed-by: Matthew Brost <[email protected]>
>
> Will get this merged once our CI system is working.
>

Applied to drm-xe-next. Thanks for patch.

Matt

> > ---
> > drivers/gpu/drm/xe/xe_vm.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> > index 4aa3943e6f29..3137cbbaabde 100644
> > --- a/drivers/gpu/drm/xe/xe_vm.c
> > +++ b/drivers/gpu/drm/xe/xe_vm.c
> > @@ -85,8 +85,8 @@ static bool preempt_fences_waiting(struct xe_vm *vm)
> >
> > list_for_each_entry(q, &vm->preempt.exec_queues, compute.link) {
> > if (!q->compute.pfence ||
> > - (q->compute.pfence && test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> > - &q->compute.pfence->flags))) {
> > + test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> > + &q->compute.pfence->flags)) {
> > return true;
> > }
> > }
> > --
> > 2.39.2
> >