{"id":810066,"url":"http://patchwork.ozlabs.org/api/patches/810066/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1504606380-49341-2-git-send-email-zyimin@linux.vnet.ibm.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/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":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1504606380-49341-2-git-send-email-zyimin@linux.vnet.ibm.com>","list_archive_url":null,"date":"2017-09-05T10:12:58","name":"[v3,1/3] s390x/pci: remove idx from msix msg data","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6f19ad994a5c67646087f6b9ef38db3454c02832","submitter":{"id":66807,"url":"http://patchwork.ozlabs.org/api/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/1504606380-49341-2-git-send-email-zyimin@linux.vnet.ibm.com/mbox/","series":[{"id":1541,"url":"http://patchwork.ozlabs.org/api/series/1541/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1541","date":"2017-09-05T10:12:57","name":"three zpci patches","version":3,"mbox":"http://patchwork.ozlabs.org/series/1541/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/810066/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/810066/checks/","tags":{},"related":[],"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 3xmjHR2h9bz9s9Y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  5 Sep 2017 20:14:11 +1000 (AEST)","from localhost ([::1]:57917 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 1dpArx-0006dI-4d\n\tfor incoming@patchwork.ozlabs.org; Tue, 05 Sep 2017 06:14:09 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:44200)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <zyimin@linux.vnet.ibm.com>) id 1dpArB-0006ZD-Ec\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 06:13:26 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <zyimin@linux.vnet.ibm.com>) id 1dpAr6-0003a1-EF\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 06:13:21 -0400","from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53636\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 1dpAr6-0003Zc-7i\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 06:13:16 -0400","from pps.filterd (m0098416.ppops.net [127.0.0.1])\n\tby mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv85A8evr194414\n\tfor <qemu-devel@nongnu.org>; Tue, 5 Sep 2017 06:13:15 -0400","from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141])\n\tby mx0b-001b2d01.pphosted.com with ESMTP id 2csndspuv5-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Tue, 05 Sep 2017 06:13:14 -0400","from localhost\n\tby e23smtp08.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\tTue, 5 Sep 2017 20:13:11 +1000","from d23relay10.au.ibm.com (202.81.31.229)\n\tby e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tTue, 5 Sep 2017 20:13:10 +1000","from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119])\n\tby d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n\tv85ADA9F42270742\n\tfor <qemu-devel@nongnu.org>; Tue, 5 Sep 2017 20:13:10 +1000","from d23av05.au.ibm.com (localhost [127.0.0.1])\n\tby d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id\n\tv85AD9ho011887\n\tfor <qemu-devel@nongnu.org>; Tue, 5 Sep 2017 20:13:10 +1000","from r35lp25.boeblingen.de.ibm.com (r35lp25.boeblingen.de.ibm.com\n\t[9.152.111.25])\n\tby d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id\n\tv85AD28Y011694; Tue, 5 Sep 2017 20:13:06 +1000"],"From":"Yi Min Zhao <zyimin@linux.vnet.ibm.com>","To":"qemu-devel@nongnu.org","Date":"Tue,  5 Sep 2017 12:12:58 +0200","X-Mailer":"git-send-email 2.3.0","In-Reply-To":"<1504606380-49341-1-git-send-email-zyimin@linux.vnet.ibm.com>","References":"<1504606380-49341-1-git-send-email-zyimin@linux.vnet.ibm.com>","X-TM-AS-MML":"disable","x-cbid":"17090510-0048-0000-0000-0000025AD726","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17090510-0049-0000-0000-0000480F334A","Message-Id":"<1504606380-49341-2-git-send-email-zyimin@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-05_05:, , 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-1709050158","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 v3 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 |  3 ++-\n target/s390x/kvm.c       | 10 +++++++---\n 5 files changed, 16 insertions(+), 39 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..ad4c5a7719 100644\n--- a/hw/s390x/s390-pci-stub.c\n+++ b/hw/s390x/s390-pci-stub.c\n@@ -70,7 +70,8 @@ S390pciState *s390_get_phb(void)\n     return NULL;\n }\n \n-S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx)\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..ebbeb4d6b3 100644\n--- a/target/s390x/kvm.c\n+++ b/target/s390x/kvm.c\n@@ -2533,12 +2533,16 @@ 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+        DPRINTF(\"add_msi_route no pci device\\n\");\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+        DPRINTF(\"add_msi_route no zpci device\\n\");\n         return -ENODEV;\n     }\n \n","prefixes":["v3","1/3"]}