xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH] x86/irq: simplify loop in unmap_domain_pirq
Date: Fri, 19 Feb 2021 15:39:14 +0100	[thread overview]
Message-ID: <f80e0026-9a0b-d25d-a0a4-81774da8cba8@suse.com> (raw)
In-Reply-To: <20210210092211.53359-1-roger.pau@citrix.com>

On 10.02.2021 10:22, Roger Pau Monne wrote:
> The for loop in unmap_domain_pirq is unnecessary complicated, with
> several places where the index is incremented, and also different
> exit conditions spread between the loop body.
> 
> Simplify it by looping over each possible PIRQ using the for loop
> syntax, and remove all possible in-loop exit points.
> 
> No functional change intended.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Quite a bit better indeed. Just one nit below (can be taken care of
while committing, once the tree will re-open).

> @@ -2356,11 +2355,23 @@ int unmap_domain_pirq(struct domain *d, int pirq)
>      if ( msi_desc != NULL )
>          pci_disable_msi(msi_desc);
>  
> -    spin_lock_irqsave(&desc->lock, flags);
> -
> -    for ( i = 0; ; )
> +    for ( i = 0; i < nr; i++, info = pirq_info(d, pirq + i) )
>      {
> +        unsigned long flags;
> +
> +        if ( !info || info->arch.irq <= 0 )
> +        {
> +            printk(XENLOG_G_ERR "dom%d: MSI pirq %d not mapped\n",
> +                   d->domain_id, pirq + i);

%pd please as you touch/move this anyway.

> @@ -2378,45 +2389,6 @@ int unmap_domain_pirq(struct domain *d, int pirq)
>              desc->msi_desc = NULL;
>          }
>  
> -        if ( ++i == nr )
> -            break;
> -
> -        spin_unlock_irqrestore(&desc->lock, flags);
> -
> -        if ( !forced_unbind )
> -           cleanup_domain_irq_pirq(d, irq, info);
> -
> -        rc = irq_deny_access(d, irq);
> -        if ( rc )
> -        {
> -            printk(XENLOG_G_ERR
> -                   "dom%d: could not deny access to IRQ%d (pirq %d)\n",
> -                   d->domain_id, irq, pirq + i);

Looks like the pirq number logged here also was off by one, which
the re-arrangement takes care of.

Jan


  reply	other threads:[~2021-02-19 14:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10  9:22 [PATCH] x86/irq: simplify loop in unmap_domain_pirq Roger Pau Monne
2021-02-19 14:39 ` Jan Beulich [this message]
2021-02-22 14:56   ` Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f80e0026-9a0b-d25d-a0a4-81774da8cba8@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).