From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlz8G-0003g6-T5 for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:56:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zlz8F-0003Ww-IF for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:56:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlz8F-0003Ws-Cu for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:56:43 -0400 Date: Tue, 13 Oct 2015 15:56:38 +0300 From: "Michael S. Tsirkin" Message-ID: <20151013125638.GA11421@redhat.com> References: <2882d261daaeeee430bcf98ea59ce47aa2bdf920.1444737974.git.p.fedin@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2882d261daaeeee430bcf98ea59ce47aa2bdf920.1444737974.git.p.fedin@samsung.com> Subject: Re: [Qemu-devel] [PATCH 2/3] hw/pci: Introduce msi_device_id() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Fedin Cc: Paolo Bonzini , qemu-devel@nongnu.org On Tue, Oct 13, 2015 at 03:12:01PM +0300, Pavel Fedin wrote: > We will need to get device IDs in KVM IRQ routing code too. This patch > introduces reusable convenient way to obtain it from the device pointer. > > Signed-off-by: Pavel Fedin What make this specific format an msi id? I think this is some kvm specific hack. If true it belongs there. > --- > hw/pci/msi.c | 2 +- > include/hw/pci/msi.h | 5 +++++ > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/hw/pci/msi.c b/hw/pci/msi.c > index f9c0484..f18bb56 100644 > --- a/hw/pci/msi.c > +++ b/hw/pci/msi.c > @@ -294,7 +294,7 @@ void msi_send_message(PCIDevice *dev, MSIMessage msg) > { > MemTxAttrs attrs = {}; > > - attrs.stream_id = (pci_bus_num(dev->bus) << 8) | dev->devfn; > + attrs.stream_id = msi_device_id(dev); > address_space_stl_le(&dev->bus_master_as, msg.address, msg.data, > attrs, NULL); > } > diff --git a/include/hw/pci/msi.h b/include/hw/pci/msi.h > index 50e452b..748bca1 100644 > --- a/include/hw/pci/msi.h > +++ b/include/hw/pci/msi.h > @@ -43,6 +43,11 @@ void msi_send_message(PCIDevice *dev, MSIMessage msg); > void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len); > unsigned int msi_nr_vectors_allocated(const PCIDevice *dev); > > +static inline uint16_t msi_device_id(PCIDevice *dev) > +{ > + return (pci_bus_num(dev->bus) << 8) | dev->devfn; > +} > + > static inline bool msi_present(const PCIDevice *dev) > { > return dev->cap_present & QEMU_PCI_CAP_MSI; > -- > 2.4.4