Re: [PATCH 4/7] xen/events: remove some simple helpers from events_base.c

From: Oleksandr Tyshchenko
Date: Mon Nov 13 2023 - 12:35:36 EST




On 16.10.23 09:28, Juergen Gross wrote:


Hello Juergen.


> The helper functions type_from_irq() and cpu_from_irq() are just one
> line functions used only internally.
>
> Open code them where needed. At the same time modify and rename
> get_evtchn_to_irq() to return a struct irq_info instead of the IRQ
> number.
>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>



[snip]



>
> @@ -1181,15 +1172,16 @@ static int bind_evtchn_to_irq_chip(evtchn_port_t evtchn, struct irq_chip *chip,
> {
> int irq;
> int ret;
> + struct irq_info *info;
>
> if (evtchn >= xen_evtchn_max_channels())
> return -ENOMEM;


I assume this check is called here (*before* holding a lock) by
intention, as evtchn_to_info() below contains the same check.

>
> mutex_lock(&irq_mapping_update_lock);
>
> - irq = get_evtchn_to_irq(evtchn);
> + info = evtchn_to_info(evtchn) >
> - if (irq == -1) {
> + if (!info) {
> irq = xen_allocate_irq_dynamic();
> if (irq < 0)
> goto out;
> @@ -1212,8 +1204,8 @@ static int bind_evtchn_to_irq_chip(evtchn_port_t evtchn, struct irq_chip *chip,
> */
> bind_evtchn_to_cpu(evtchn, 0, false);
> } else {
> - struct irq_info *info = info_for_irq(irq);
> - WARN_ON(info == NULL || info->type != IRQT_EVTCHN);
> + WARN_ON(info->type != IRQT_EVTCHN);
> + irq = info->irq;
> }


This hunk doesn't apply clearly to the latest state, because of
"9e90e58c11b7 xen: evtchn: Allow shared registration of IRQ handers"
went in. Please rebase.


With that:
Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>


Also checkpatch.pl warns about BUG_ON usage in several places, but again
you didn't introduce them in current patch, just touched their args.


[snip]