From patchwork Sun May 31 18:37:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 478691 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D009140FDF for ; Mon, 1 Jun 2015 04:48:59 +1000 (AEST) Received: from localhost ([::1]:42997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yz8I5-00044L-99 for incoming@patchwork.ozlabs.org; Sun, 31 May 2015 14:48:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yz86o-00016v-Hy for qemu-devel@nongnu.org; Sun, 31 May 2015 14:37:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yz86n-0005Z8-Im for qemu-devel@nongnu.org; Sun, 31 May 2015 14:37:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yz86n-0005Yw-CO for qemu-devel@nongnu.org; Sun, 31 May 2015 14:37:17 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 09998373BD0; Sun, 31 May 2015 18:37:16 +0000 (UTC) Received: from redhat.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t4VIbDqj017125; Sun, 31 May 2015 14:37:14 -0400 Date: Sun, 31 May 2015 20:37:13 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1433097192-8988-46-git-send-email-mst@redhat.com> References: <1433097192-8988-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1433097192-8988-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Pavel Fedin Subject: [Qemu-devel] [PULL 45/57] Add stream ID to MSI write X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Pavel Fedin GICv3 ITS distinguishes between devices by using hardwired device IDs passed on the bus. This patch implements passing these IDs in qemu. SMMU is also known to use stream IDs, therefore this addition can also be useful for implementing platforms with SMMU. Signed-off-by: Pavel Fedin Reviewed-by: Michael S. Tsirkin Changes from v1: - Added bus number to the stream ID - Added stream ID not only to MSI-X, but also to plain MSI. Some common code was made into msi_send_message() function. Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/memattrs.h | 2 ++ include/hw/pci/msi.h | 1 + hw/pci/msi.c | 10 +++++++++- hw/pci/msix.c | 3 +-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h index 1389b4b..96dc440 100644 --- a/include/exec/memattrs.h +++ b/include/exec/memattrs.h @@ -33,6 +33,8 @@ typedef struct MemTxAttrs { unsigned int secure:1; /* Memory access is usermode (unprivileged) */ unsigned int user:1; + /* Stream ID (for MSI for example) */ + unsigned int stream_id:16; } MemTxAttrs; /* Bus masters which don't specify any attributes will get this, diff --git a/include/hw/pci/msi.h b/include/hw/pci/msi.h index 81a3848..50e452b 100644 --- a/include/hw/pci/msi.h +++ b/include/hw/pci/msi.h @@ -39,6 +39,7 @@ int msi_init(struct PCIDevice *dev, uint8_t offset, void msi_uninit(struct PCIDevice *dev); void msi_reset(PCIDevice *dev); void msi_notify(PCIDevice *dev, unsigned int vector); +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); diff --git a/hw/pci/msi.c b/hw/pci/msi.c index 2949938..c111dba 100644 --- a/hw/pci/msi.c +++ b/hw/pci/msi.c @@ -291,8 +291,16 @@ void msi_notify(PCIDevice *dev, unsigned int vector) "notify vector 0x%x" " address: 0x%"PRIx64" data: 0x%"PRIx32"\n", vector, msg.address, msg.data); + msi_send_message(dev, msg); +} + +void msi_send_message(PCIDevice *dev, MSIMessage msg) +{ + MemTxAttrs attrs = {}; + + attrs.stream_id = (pci_bus_num(dev->bus) << 8) | dev->devfn; address_space_stl_le(&dev->bus_master_as, msg.address, msg.data, - MEMTXATTRS_UNSPECIFIED, NULL); + attrs, NULL); } /* Normally called by pci_default_write_config(). */ diff --git a/hw/pci/msix.c b/hw/pci/msix.c index 9935f98..7716bf3 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -443,8 +443,7 @@ void msix_notify(PCIDevice *dev, unsigned vector) msg = msix_get_message(dev, vector); - address_space_stl_le(&dev->bus_master_as, msg.address, msg.data, - MEMTXATTRS_UNSPECIFIED, NULL); + msi_send_message(dev, msg); } void msix_reset(PCIDevice *dev)