{"id":806430,"url":"http://patchwork.ozlabs.org/api/1.0/patches/806430/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<1503907487-2764-3-git-send-email-zyimin@linux.vnet.ibm.com>","date":"2017-08-28T08:04:45","name":"[2/4] s390x/pci: remove idx from msix msg data","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8f310fb4d2957ad5545f7b5de52f8bcac750aedb","submitter":{"id":66807,"url":"http://patchwork.ozlabs.org/api/1.0/people/66807/?format=json","name":"Yi Min Zhao","email":"zyimin@linux.vnet.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1503907487-2764-3-git-send-email-zyimin@linux.vnet.ibm.com/mbox/","series":[{"id":98,"url":"http://patchwork.ozlabs.org/api/1.0/series/98/?format=json","date":"2017-08-28T08:04:43","name":"four zpci patches","version":1,"mbox":"http://patchwork.ozlabs.org/series/98/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806430/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xgkqQ2VsSz9sNq\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 28 Aug 2017 18:06:10 +1000 (AEST)","from localhost ([::1]:37401 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dmF3g-00088C-7x\n\tfor incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 04:06:08 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:55407)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <zyimin@linux.vnet.ibm.com>) id 1dmF2n-00083r-VH\n\tfor qemu-devel@nongnu.org; Mon, 28 Aug 2017 04:05:18 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <zyimin@linux.vnet.ibm.com>) id 1dmF2j-00068Z-OS\n\tfor qemu-devel@nongnu.org; Mon, 28 Aug 2017 04:05:13 -0400","from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36750\n\thelo=mx0a-001b2d01.pphosted.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <zyimin@linux.vnet.ibm.com>)\n\tid 1dmF2j-00068A-Ia\n\tfor qemu-devel@nongnu.org; Mon, 28 Aug 2017 04:05:09 -0400","from pps.filterd (m0098419.ppops.net [127.0.0.1])\n\tby mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv7S83tWf093617\n\tfor <qemu-devel@nongnu.org>; Mon, 28 Aug 2017 04:05:09 -0400","from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144])\n\tby mx0b-001b2d01.pphosted.com with ESMTP id 2cmb2r264e-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Mon, 28 Aug 2017 04:05:08 -0400","from localhost\n\tby e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <qemu-devel@nongnu.org> from <zyimin@linux.vnet.ibm.com>;\n\tMon, 28 Aug 2017 18:05:05 +1000","from d23relay09.au.ibm.com (202.81.31.228)\n\tby e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tMon, 28 Aug 2017 18:05:02 +1000","from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138])\n\tby d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n\tv7S8525O41746626\n\tfor <qemu-devel@nongnu.org>; Mon, 28 Aug 2017 18:05:02 +1000","from d23av02.au.ibm.com (localhost [127.0.0.1])\n\tby d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id\n\tv7S84qjx025899\n\tfor <qemu-devel@nongnu.org>; Mon, 28 Aug 2017 18:04:53 +1000","from r35lp25.boeblingen.de.ibm.com (r35lp25.boeblingen.de.ibm.com\n\t[9.152.111.25])\n\tby d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id\n\tv7S84gjH025538; Mon, 28 Aug 2017 18:04:50 +1000"],"From":"Yi Min Zhao <zyimin@linux.vnet.ibm.com>","To":"qemu-devel@nongnu.org","Date":"Mon, 28 Aug 2017 10:04:45 +0200","X-Mailer":"git-send-email 2.3.0","In-Reply-To":"<1503907487-2764-1-git-send-email-zyimin@linux.vnet.ibm.com>","References":"<1503907487-2764-1-git-send-email-zyimin@linux.vnet.ibm.com>","X-TM-AS-MML":"disable","x-cbid":"17082808-0004-0000-0000-0000022B8C17","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17082808-0005-0000-0000-00005E12892D","Message-Id":"<1503907487-2764-3-git-send-email-zyimin@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-08-28_04:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=1\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1708280128","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]","X-Received-From":"148.163.158.5","Subject":"[Qemu-devel] [PATCH 2/4] s390x/pci: remove idx from msix msg data","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"pasic@linux.vnet.ibm.com, zyimin@linux.vnet.ibm.com,\n\trichard.henderson@linaro.org, cohuck@redhat.com,\n\tpmorel@linux.vnet.ibm.com, agraf@suse.de, borntraeger@de.ibm.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"PCIDevcie pointer has been a parameter of kvm_arch_fixup_msi_route().\nSo we don't need to store zpci idx in msix message data to find out the\nspecific zpci device. Instead, we could use pci device id to find its\ncorresponding zpci device.\n\nSigned-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>\n---\n hw/s390x/s390-pci-bus.c  | 16 +++++-----------\n hw/s390x/s390-pci-bus.h  |  2 ++\n hw/s390x/s390-pci-inst.c | 24 ------------------------\n target/s390x/kvm.c       |  7 +++++--\n 4 files changed, 12 insertions(+), 37 deletions(-)","diff":"diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c\nindex 61cfd2138f..9e1f7ff5c5 100644\n--- a/hw/s390x/s390-pci-bus.c\n+++ b/hw/s390x/s390-pci-bus.c\n@@ -209,8 +209,8 @@ static S390PCIBusDevice *s390_pci_find_dev_by_uid(S390pciState *s, uint16_t uid)\n     return NULL;\n }\n \n-static S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciState *s,\n-                                                     const char *target)\n+S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciState *s,\n+                                              const char *target)\n {\n     S390PCIBusDevice *pbdev;\n \n@@ -475,19 +475,13 @@ static void s390_msi_ctrl_write(void *opaque, hwaddr addr, uint64_t data,\n                                 unsigned int size)\n {\n     S390PCIBusDevice *pbdev = opaque;\n-    uint32_t idx = data >> ZPCI_MSI_VEC_BITS;\n     uint32_t vec = data & ZPCI_MSI_VEC_MASK;\n     uint64_t ind_bit;\n     uint32_t sum_bit;\n-    uint32_t e = 0;\n \n-    DPRINTF(\"write_msix data 0x%\" PRIx64 \" idx %d vec 0x%x\\n\", data, idx, vec);\n-\n-    if (!pbdev) {\n-        e |= (vec << ERR_EVENT_MVN_OFFSET);\n-        s390_pci_generate_error_event(ERR_EVENT_NOMSI, idx, 0, addr, e);\n-        return;\n-    }\n+    assert(pbdev);\n+    DPRINTF(\"write_msix data 0x%\" PRIx64 \" idx %d vec 0x%x\\n\", data,\n+            pbdev->idx, vec);\n \n     if (pbdev->state != ZPCI_FS_ENABLED) {\n         return;\ndiff --git a/hw/s390x/s390-pci-bus.h b/hw/s390x/s390-pci-bus.h\nindex 67af2c12ff..820c7fa52b 100644\n--- a/hw/s390x/s390-pci-bus.h\n+++ b/hw/s390x/s390-pci-bus.h\n@@ -330,6 +330,8 @@ void s390_pci_generate_error_event(uint16_t pec, uint32_t fh, uint32_t fid,\n S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx);\n S390PCIBusDevice *s390_pci_find_dev_by_fh(S390pciState *s, uint32_t fh);\n S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid);\n+S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciState *s,\n+                                              const char *target);\n S390PCIBusDevice *s390_pci_find_next_avail_dev(S390pciState *s,\n                                                S390PCIBusDevice *pbdev);\n \ndiff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c\nindex eba9ffb5f2..8e088f3dc9 100644\n--- a/hw/s390x/s390-pci-inst.c\n+++ b/hw/s390x/s390-pci-inst.c\n@@ -413,29 +413,6 @@ int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)\n     return 0;\n }\n \n-static void update_msix_table_msg_data(S390PCIBusDevice *pbdev, uint64_t offset,\n-                                       uint64_t *data, uint8_t len)\n-{\n-    uint32_t val;\n-    uint8_t *msg_data;\n-\n-    if (offset % PCI_MSIX_ENTRY_SIZE != 8) {\n-        return;\n-    }\n-\n-    if (len != 4) {\n-        DPRINTF(\"access msix table msg data but len is %d\\n\", len);\n-        return;\n-    }\n-\n-    msg_data = (uint8_t *)data - offset % PCI_MSIX_ENTRY_SIZE +\n-               PCI_MSIX_ENTRY_VECTOR_CTRL;\n-    val = pci_get_long(msg_data) |\n-        ((pbdev->fh & FH_MASK_INDEX) << ZPCI_MSI_VEC_BITS);\n-    pci_set_long(msg_data, val);\n-    DPRINTF(\"update msix msg_data to 0x%\" PRIx64 \"\\n\", *data);\n-}\n-\n static int trap_msix(S390PCIBusDevice *pbdev, uint64_t offset, uint8_t pcias)\n {\n     if (pbdev->msix.available && pbdev->msix.table_bar == pcias &&\n@@ -508,7 +485,6 @@ int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)\n         if (trap_msix(pbdev, offset, pcias)) {\n             offset = offset - pbdev->msix.table_offset;\n             mr = &pbdev->pdev->msix_table_mmio;\n-            update_msix_table_msg_data(pbdev, offset, &data, len);\n         } else {\n             mr = pbdev->pdev->io_regions[pcias].memory;\n         }\ndiff --git a/target/s390x/kvm.c b/target/s390x/kvm.c\nindex 1c68c36663..e348bfb7cc 100644\n--- a/target/s390x/kvm.c\n+++ b/target/s390x/kvm.c\n@@ -2503,10 +2503,13 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,\n                              uint64_t address, uint32_t data, PCIDevice *dev)\n {\n     S390PCIBusDevice *pbdev;\n-    uint32_t idx = data >> ZPCI_MSI_VEC_BITS;\n     uint32_t vec = data & ZPCI_MSI_VEC_MASK;\n \n-    pbdev = s390_pci_find_dev_by_idx(s390_get_phb(), idx);\n+    if (!dev) {\n+        return -ENODEV;\n+    }\n+\n+    pbdev = s390_pci_find_dev_by_target(s390_get_phb(), DEVICE(dev)->id);\n     if (!pbdev) {\n         DPRINTF(\"add_msi_route no dev\\n\");\n         return -ENODEV;\n","prefixes":["2/4"]}