{"id":808525,"url":"http://patchwork.ozlabs.org/api/1.0/patches/808525/?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":"<1504239778-29893-2-git-send-email-zyimin@linux.vnet.ibm.com>","date":"2017-09-01T04:22:56","name":"[v2,1/3] s390x/pci: remove idx from msix msg data","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7a921b03777485393a9a19acca233fdebaced1c1","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/1504239778-29893-2-git-send-email-zyimin@linux.vnet.ibm.com/mbox/","series":[{"id":947,"url":"http://patchwork.ozlabs.org/api/1.0/series/947/?format=json","date":"2017-09-01T04:22:55","name":"three zpci patches","version":2,"mbox":"http://patchwork.ozlabs.org/series/947/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808525/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 3xk5kd5yzcz9s0g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 14:25:13 +1000 (AEST)","from localhost ([::1]:45113 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 1dndW3-0004iv-RK\n\tfor incoming@patchwork.ozlabs.org; Fri, 01 Sep 2017 00:25:11 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:34973)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <zyimin@linux.vnet.ibm.com>) id 1dndVU-0004hZ-Ev\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 00:24:37 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <zyimin@linux.vnet.ibm.com>) id 1dndVQ-00029h-GC\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 00:24:36 -0400","from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41792)\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 1dndVQ-00029F-82\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 00:24:32 -0400","from pps.filterd (m0098399.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv814NpZL099972\n\tfor <qemu-devel@nongnu.org>; Fri, 1 Sep 2017 00:24:30 -0400","from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2cpx0a0uhu-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Fri, 01 Sep 2017 00:24:30 -0400","from localhost\n\tby e23smtp06.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\tFri, 1 Sep 2017 14:24:27 +1000","from d23relay10.au.ibm.com (202.81.31.229)\n\tby e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tFri, 1 Sep 2017 14:24:25 +1000","from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151])\n\tby d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n\tv814NAAk33816618\n\tfor <qemu-devel@nongnu.org>; Fri, 1 Sep 2017 14:23:10 +1000","from d23av06.au.ibm.com (localhost [127.0.0.1])\n\tby d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id\n\tv814N9eZ001188\n\tfor <qemu-devel@nongnu.org>; Fri, 1 Sep 2017 14:23:10 +1000","from r35lp25.boeblingen.de.ibm.com (r35lp25.boeblingen.de.ibm.com\n\t[9.152.111.25])\n\tby d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id\n\tv814N2UC001078; Fri, 1 Sep 2017 14:23:06 +1000"],"From":"Yi Min Zhao <zyimin@linux.vnet.ibm.com>","To":"qemu-devel@nongnu.org","Date":"Fri,  1 Sep 2017 06:22:56 +0200","X-Mailer":"git-send-email 2.3.0","In-Reply-To":"<1504239778-29893-1-git-send-email-zyimin@linux.vnet.ibm.com>","References":"<1504239778-29893-1-git-send-email-zyimin@linux.vnet.ibm.com>","X-TM-AS-MML":"disable","x-cbid":"17090104-0040-0000-0000-000003525892","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17090104-0041-0000-0000-00000CD06048","Message-Id":"<1504239778-29893-2-git-send-email-zyimin@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-08-31_09:, , 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-1709010064","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]","X-Received-From":"148.163.156.1","Subject":"[Qemu-devel] [PATCH v2 1/3] 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":"PCIDevice 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 hw/s390x/s390-pci-stub.c |  6 ++++++\n target/s390x/kvm.c       |  7 +++++--\n 5 files changed, 18 insertions(+), 37 deletions(-)","diff":"diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c\nindex 0a31a4ae88..bd8a3e1e1c 100644\n--- a/hw/s390x/s390-pci-bus.c\n+++ b/hw/s390x/s390-pci-bus.c\n@@ -199,8 +199,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@@ -465,19 +465,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 bd636abc28..560bd82a0f 100644\n--- a/hw/s390x/s390-pci-bus.h\n+++ b/hw/s390x/s390-pci-bus.h\n@@ -322,6 +322,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/hw/s390x/s390-pci-stub.c b/hw/s390x/s390-pci-stub.c\nindex 7a642d376c..e501e1b9ea 100644\n--- a/hw/s390x/s390-pci-stub.c\n+++ b/hw/s390x/s390-pci-stub.c\n@@ -74,3 +74,9 @@ S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx)\n {\n     return NULL;\n }\n+\n+S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciState *s,\n+                                              const char *target)\n+{\n+    return NULL;\n+}\ndiff --git a/target/s390x/kvm.c b/target/s390x/kvm.c\nindex 1338c29528..3d490c5e4b 100644\n--- a/target/s390x/kvm.c\n+++ b/target/s390x/kvm.c\n@@ -2533,10 +2533,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":["v2","1/3"]}