All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Thomas Huth" <thuth@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
	"yang zhong" <yang.zhong@intel.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [Qemu-trivial] [PATCH] hw/pci/pci-stub: Add msi_enabled() and msi_notify() to the pci stubs
Date: Tue, 19 Feb 2019 22:35:45 -0500	[thread overview]
Message-ID: <20190219222058-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1590333482.2281318.1550618370282.JavaMail.zimbra@redhat.com>

On Tue, Feb 19, 2019 at 06:19:30PM -0500, Paolo Bonzini wrote:
> 
> > > Makes sense, but it is also abstraction time. :)  What if instead there
> > > was a function
> > > 
> > > void msi_allocate_irqs(PCIDevice *pdev, int num, bool fallback_to_intx);
> > > 
> > > and then ich.c did
> > > 
> > >     irqs = msi_allocate_irqs(pdev, 1, true);
> > >     s->irq = irqs[0];
> > >     g_free(irqs);
> > > 
> > > ?  "if msi_enabled raise MSI else raise INTX" is really a common idiom.
> > > 
> > > Thanks,
> > > 
> > > Paolo
> > 
> > Maybe it is but the specific issue is not about fallback to INTX of PCI
> > (is the fallback broken for ahci? I don't know).
> 
> It works, the above is just a new abstraction.
> 
> > The trick is there's no pdev at all.
> 
> The trick :) is that in ich.c there is a pdev.  Right now we are assigning to
> s->irq either the INTX irq (if PCI) or a sysbus irq (if sysbus), but then
> we need to know about MSI with a wrapper around s->irq.

Oh you mean just for PCI.

> Instead, my suggestion is to put the wrapper in the PCI core as a qemu_irq
> callback---or perhaps in ich.c, but anyway ahci.c should not care that there
> could be a PCI AHCI device and it would have two different interrupt modes.

I like it very much that devices call pci_set_irq, I'd rather not
have callbacks.


I think the wrapper thay calls either pci_set_irq isn't a problem,
problem is MSI/X has multiple vectors, INTX doesn't.
So for many devices there's something extra that happens
just in one mode but not the other to deal with multiple vectors.

So I don't think it can be an abstraction that everyone
uses. But yes it can be a helper function.

In fact mptsas_update_interrupt seems not to be
PCI spec compliant: it sets both MSI and INTX.

CC original contributor with this question.



> In fact, doing this would also remove the need for s->container, I think.
> 
> Paolo


WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Thomas Huth" <thuth@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
	"yang zhong" <yang.zhong@intel.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [Qemu-devel] [PATCH] hw/pci/pci-stub: Add msi_enabled() and msi_notify() to the pci stubs
Date: Tue, 19 Feb 2019 22:35:45 -0500	[thread overview]
Message-ID: <20190219222058-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1590333482.2281318.1550618370282.JavaMail.zimbra@redhat.com>

On Tue, Feb 19, 2019 at 06:19:30PM -0500, Paolo Bonzini wrote:
> 
> > > Makes sense, but it is also abstraction time. :)  What if instead there
> > > was a function
> > > 
> > > void msi_allocate_irqs(PCIDevice *pdev, int num, bool fallback_to_intx);
> > > 
> > > and then ich.c did
> > > 
> > >     irqs = msi_allocate_irqs(pdev, 1, true);
> > >     s->irq = irqs[0];
> > >     g_free(irqs);
> > > 
> > > ?  "if msi_enabled raise MSI else raise INTX" is really a common idiom.
> > > 
> > > Thanks,
> > > 
> > > Paolo
> > 
> > Maybe it is but the specific issue is not about fallback to INTX of PCI
> > (is the fallback broken for ahci? I don't know).
> 
> It works, the above is just a new abstraction.
> 
> > The trick is there's no pdev at all.
> 
> The trick :) is that in ich.c there is a pdev.  Right now we are assigning to
> s->irq either the INTX irq (if PCI) or a sysbus irq (if sysbus), but then
> we need to know about MSI with a wrapper around s->irq.

Oh you mean just for PCI.

> Instead, my suggestion is to put the wrapper in the PCI core as a qemu_irq
> callback---or perhaps in ich.c, but anyway ahci.c should not care that there
> could be a PCI AHCI device and it would have two different interrupt modes.

I like it very much that devices call pci_set_irq, I'd rather not
have callbacks.


I think the wrapper thay calls either pci_set_irq isn't a problem,
problem is MSI/X has multiple vectors, INTX doesn't.
So for many devices there's something extra that happens
just in one mode but not the other to deal with multiple vectors.

So I don't think it can be an abstraction that everyone
uses. But yes it can be a helper function.

In fact mptsas_update_interrupt seems not to be
PCI spec compliant: it sets both MSI and INTX.

CC original contributor with this question.



> In fact, doing this would also remove the need for s->container, I think.
> 
> Paolo

  reply	other threads:[~2019-02-20  3:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 16:07 [Qemu-trivial] [PATCH] hw/pci/pci-stub: Add msi_enabled() and msi_notify() to the pci stubs Thomas Huth
2019-02-19 16:07 ` [Qemu-devel] " Thomas Huth
2019-02-19 17:23 ` [Qemu-trivial] " Philippe Mathieu-Daudé
2019-02-19 17:23   ` Philippe Mathieu-Daudé
2019-02-19 18:24 ` [Qemu-trivial] " Paolo Bonzini
2019-02-19 18:24   ` [Qemu-devel] " Paolo Bonzini
2019-02-19 20:23   ` [Qemu-trivial] " Michael S. Tsirkin
2019-02-19 20:23     ` [Qemu-devel] " Michael S. Tsirkin
2019-02-19 23:19     ` [Qemu-trivial] " Paolo Bonzini
2019-02-19 23:19       ` [Qemu-devel] " Paolo Bonzini
2019-02-20  3:35       ` Michael S. Tsirkin [this message]
2019-02-20  3:35         ` Michael S. Tsirkin
2019-02-19 20:19 ` [Qemu-trivial] " Michael S. Tsirkin
2019-02-19 20:19   ` [Qemu-devel] " Michael S. Tsirkin
2019-02-20  6:24   ` [Qemu-trivial] " Thomas Huth
2019-02-20  6:24     ` [Qemu-devel] " Thomas Huth
2019-02-21 16:55     ` [Qemu-trivial] " Michael S. Tsirkin
2019-02-21 16:55       ` [Qemu-devel] " Michael S. Tsirkin
2019-02-21 18:00       ` [Qemu-trivial] " Paolo Bonzini
2019-02-21 18:00         ` [Qemu-devel] " Paolo Bonzini

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=20190219222058-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=yang.zhong@intel.com \
    /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 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.