From: Alexander Gordeev <agordeev@redhat.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-mips@linux-mips.org, linux-s390@vger.kernel.org,
linux-pci@vger.kernel.org, x86@kernel.org,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/2] PCI/MSI: Phase out pci_enable_msi_block()
Date: Thu, 1 May 2014 18:07:39 +0200 [thread overview]
Message-ID: <20140501160738.GA10407@dhcp-26-207.brq.redhat.com> (raw)
In-Reply-To: <20140430234933.GB31315@google.com>
On Wed, Apr 30, 2014 at 05:49:33PM -0600, Bjorn Helgaas wrote:
> I mistakenly assumed this would have to wait because I thought there were
> other pci_enable_msi_block() users that wouldn't be removed until the v3.16
> merge window. But I think I was wrong: I put your GenWQE patch in my tree,
> and I think that was the last use, so I can just add this patch on top.
That is right, GenWQE is the last one.
> But I need a little help understanding the changelog:
>
> > Up until now, when enabling MSI mode for a device a single
> > successful call to arch_msi_check_device() was followed by
> > a single call to arch_setup_msi_irqs() function.
>
> I understand this part; the following two paths call
> arch_msi_check_device() once and then arch_setup_msi_irqs() once:
>
> pci_enable_msi_block
> pci_msi_check_device
> arch_msi_check_device
> msi_capability_init
> arch_setup_msi_irqs
>
> pci_enable_msix
> pci_msi_check_device
> arch_msi_check_device
> msix_capability_init
> arch_setup_msi_irqs
>
> > Yet, if arch_msi_check_device() returned success we should be
> > able to call arch_setup_msi_irqs() multiple times - while it
> > returns a number of MSI vectors that could have been allocated
> > (a third state).
>
> I don't know what you mean by "a third state."
That is "a number of MSI vectors that could have been allocated", which
is neither success nor failure. In previous conversations someone branded
it this as "third state".
> Previously we only called arch_msi_check_device() once. After your patch,
> pci_enable_msi_range() can call it several times. The only non-trivial
> implementation of arch_msi_check_device() is in powerpc, and all the
> ppc_md.msi_check_device() possibilities look safe to call multiple times.
Yep, I see it the same way.
> After your patch, the pci_enable_msi_range() path can also call
> arch_setup_msi_irqs() several times. I don't see a problem with that --
> even if the first call succeeds and allocates something, then a subsequent
> call fails, I assume the allocations will be cleaned up when
> msi_capability_init() calls free_msi_irqs().
Well, the potential problem related to the fact arch_msi_check_device()
could be called with 'nvec1' while arch_setup_msi_irqs() could be called
with 'nvec2', where 'nvec1' > 'nvec2'.
While it is not a problem with current implementations, in therory it is
possible free_msi_irqs() could be called with 'nvec2' and fail to clean
up 'nvec1' - 'nvec2' number of resources.
The only assumption that makes the above scenario impossible is if
arch_msi_check_device() is stateless.
Again, that is purely theoretical with no particular architecture in mind.
> > This update makes use of the assumption described above. It
> > could have broke things had the architectures done any pre-
> > allocations or switch to some state in a call to function
> > arch_msi_check_device(). But because arch_msi_check_device()
> > is expected stateless and MSI resources are allocated in a
> > follow-up call to arch_setup_msi_irqs() we should be fine.
>
> I guess you mean that your patch assumes arch_msi_check_device() is
> stateless. That looks like a safe assumption to me.
Moreover, if arch_msi_check_device() was not stateless then it would
be superfluous, since all state switches and allocations are done in
arch_setup_msi_irqs() anyway.
In fact, I think arch_msi_check_device() could be eliminated, but I
do not want to engage with PPC folks at this stage ;)
> arch_setup_msi_irqs() is clearly not stateless, but I assume
> free_msi_irqs() is enough to clean up any state if we fail.
>
> Bjorn
--
Regards,
Alexander Gordeev
agordeev@redhat.com
prev parent reply other threads:[~2014-05-01 16:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-14 7:14 [PATCH 0/2] Phase out pci_enable_msi_block() Alexander Gordeev
2014-04-14 7:14 ` [PATCH 2/2] PCI/MSI: " Alexander Gordeev
2014-04-14 12:09 ` Alexander Gordeev
2014-04-14 13:28 ` Alexander Gordeev
2014-04-30 21:19 ` Alexander Gordeev
2014-04-30 23:49 ` Bjorn Helgaas
2014-05-01 16:07 ` Alexander Gordeev [this message]
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=20140501160738.GA10407@dhcp-26-207.brq.redhat.com \
--to=agordeev@redhat.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=x86@kernel.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).