All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] irqchip: irq-gic-v4: return real error code
  2018-03-19 11:38 [PATCH] irqchip: irq-gic-v4: return real error code Peng Hao
@ 2018-03-19  8:30 ` Marc Zyngier
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2018-03-19  8:30 UTC (permalink / raw)
  To: Peng Hao, tglx, jason; +Cc: linux-kernel

On 19/03/18 11:38, Peng Hao wrote:
> __irq_domain_alloc_irqs will return some different error code, so we
> should return real error code in its_alloc_vcpu_irqs.

What do we gain by doing so? Do we end-up treating the error in a
different way? What does this actually improve? This is the kind of
information I'm looking for in a commit message. Not something that
describes the patch.

> 
> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> ---
>  drivers/irqchip/irq-gic-v4.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
> index dba9d67..ecd170d 100644
> --- a/drivers/irqchip/irq-gic-v4.c
> +++ b/drivers/irqchip/irq-gic-v4.c
> @@ -99,7 +99,7 @@
>  
>  int its_alloc_vcpu_irqs(struct its_vm *vm)
>  {
> -	int vpe_base_irq, i;
> +	int vpe_base_irq, i, ret = -ENOMEM;
>  
>  	vm->fwnode = irq_domain_alloc_named_id_fwnode("GICv4-vpe",
>  						      task_pid_nr(current));
> @@ -120,8 +120,10 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
>  	vpe_base_irq = __irq_domain_alloc_irqs(vm->domain, -1, vm->nr_vpes,
>  					       NUMA_NO_NODE, vm,
>  					       false, NULL);
> -	if (vpe_base_irq <= 0)
> +	if (vpe_base_irq <= 0) {
> +		ret = vpe_base_irq;
>  		goto err;

Given that a return value of zero denotes an actual error, we can now
pretend that everything went smoothly, except that none of the doorbells
are initialized. KVM will then try and request the interrupts, which
will fail (because 0 is not a valid interrupt number).

We thus went from a situation where the error was completely unambiguous
(failed to allocate a bunch of interrupts) to a situation where things
fail in a bizarre way because we cannot request the interrupts that we
just allocated (something that shouldn't really fail).

I cannot call this change a real improvement.

> +	}
>  
>  	for (i = 0; i < vm->nr_vpes; i++)
>  		vm->vpes[i]->irq = vpe_base_irq + i;
> @@ -134,7 +136,7 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
>  	if (vm->fwnode)
>  		irq_domain_free_fwnode(vm->fwnode);
>  
> -	return -ENOMEM;
> +	return ret;
>  }
>  
>  void its_free_vcpu_irqs(struct its_vm *vm)
> 

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] irqchip: irq-gic-v4: return real error code
@ 2018-03-19 11:38 Peng Hao
  2018-03-19  8:30 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Hao @ 2018-03-19 11:38 UTC (permalink / raw)
  To: tglx, jason, marc.zyngier; +Cc: linux-kernel, Peng Hao

__irq_domain_alloc_irqs will return some different error code, so we
should return real error code in its_alloc_vcpu_irqs.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 drivers/irqchip/irq-gic-v4.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
index dba9d67..ecd170d 100644
--- a/drivers/irqchip/irq-gic-v4.c
+++ b/drivers/irqchip/irq-gic-v4.c
@@ -99,7 +99,7 @@
 
 int its_alloc_vcpu_irqs(struct its_vm *vm)
 {
-	int vpe_base_irq, i;
+	int vpe_base_irq, i, ret = -ENOMEM;
 
 	vm->fwnode = irq_domain_alloc_named_id_fwnode("GICv4-vpe",
 						      task_pid_nr(current));
@@ -120,8 +120,10 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
 	vpe_base_irq = __irq_domain_alloc_irqs(vm->domain, -1, vm->nr_vpes,
 					       NUMA_NO_NODE, vm,
 					       false, NULL);
-	if (vpe_base_irq <= 0)
+	if (vpe_base_irq <= 0) {
+		ret = vpe_base_irq;
 		goto err;
+	}
 
 	for (i = 0; i < vm->nr_vpes; i++)
 		vm->vpes[i]->irq = vpe_base_irq + i;
@@ -134,7 +136,7 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
 	if (vm->fwnode)
 		irq_domain_free_fwnode(vm->fwnode);
 
-	return -ENOMEM;
+	return ret;
 }
 
 void its_free_vcpu_irqs(struct its_vm *vm)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-19  8:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 11:38 [PATCH] irqchip: irq-gic-v4: return real error code Peng Hao
2018-03-19  8:30 ` Marc Zyngier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.