From nobody Wed May 8 22:26:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148801110301129.783095355715773; Sat, 25 Feb 2017 00:25:03 -0800 (PST) Received: from localhost ([::1]:41744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXf3-0006Lp-PY for importer@patchew.org; Sat, 25 Feb 2017 03:25:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa1-0001VS-An for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chXZy-0008SZ-Vd for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:49 -0500 Received: from [59.151.112.132] (port=45078 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXZy-0008R1-0V for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:46 -0500 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Feb 2017 16:19:19 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 88E4F47C4EAE; Sat, 25 Feb 2017 16:19:18 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 25 Feb 2017 16:19:18 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15950440" From: Cao jin To: Date: Sat, 25 Feb 2017 16:26:35 +0800 Message-ID: <1488011202-32121-2-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: 88E4F47C4EAE.ADFD6 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v10 1/8] msix: Rename and create a wrapper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Alex Williamson , Markus Armbruster , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename msix_init to msix_validate_and_init, and use it from vfio which might get a reasonable -EINVAL. New a wrapper msix_init which assert the programming error for debug purpose and use it from other devices. CC: Alex Williamson CC: Markus Armbruster CC: Marcel Apfelbaum CC: Michael S. Tsirkin Signed-off-by: Cao jin --- hw/pci/msix.c | 30 +++++++++++++++++++++--------- hw/vfio/pci.c | 12 ++++++------ include/hw/pci/msix.h | 5 +++++ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/hw/pci/msix.c b/hw/pci/msix.c index bb54e8b0ac37..2b7541ab2c8d 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -239,6 +239,19 @@ static void msix_mask_all(struct PCIDevice *dev, unsig= ned nentries) } } =20 +/* Just a wrapper to check the return value */ +int msix_init(struct PCIDevice *dev, unsigned short nentries, + MemoryRegion *table_bar, uint8_t table_bar_nr, + unsigned table_offset, MemoryRegion *pba_bar, + uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos, + Error **errp) +{ + int ret =3D msix_validate_and_init(dev, nentries, table_bar, table_bar= _nr, + table_offset, pba_bar, pba_bar_nr, pba_offset, cap_pos, errp); + + assert(ret !=3D -EINVAL); + return ret; +} /* * Make PCI device @dev MSI-X capable * @nentries is the max number of MSI-X vectors that the device support. @@ -259,11 +272,11 @@ static void msix_mask_all(struct PCIDevice *dev, unsi= gned nentries) * also means a programming error, except device assignment, which can che= ck * if a real HW is broken. */ -int msix_init(struct PCIDevice *dev, unsigned short nentries, - MemoryRegion *table_bar, uint8_t table_bar_nr, - unsigned table_offset, MemoryRegion *pba_bar, - uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos, - Error **errp) +int msix_validate_and_init(struct PCIDevice *dev, unsigned short nentries, + MemoryRegion *table_bar, uint8_t table_bar_nr, + unsigned table_offset, MemoryRegion *pba_bar, + uint8_t pba_bar_nr, unsigned pba_offset, + uint8_t cap_pos, Error **errp) { int cap; unsigned table_size, pba_size; @@ -361,10 +374,9 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned s= hort nentries, memory_region_init(&dev->msix_exclusive_bar, OBJECT(dev), name, bar_si= ze); g_free(name); =20 - ret =3D msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr, - 0, &dev->msix_exclusive_bar, - bar_nr, bar_pba_offset, - 0, errp); + ret =3D msix_validate_and_init(dev, nentries, &dev->msix_exclusive_bar, + bar_nr, 0, &dev->msix_exclusive_bar, + bar_nr, bar_pba_offset, 0, errp); if (ret) { return ret; } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 332f41d6627f..06828b537a75 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1436,12 +1436,12 @@ static int vfio_msix_setup(VFIOPCIDevice *vdev, int= pos, Error **errp) =20 vdev->msix->pending =3D g_malloc0(BITS_TO_LONGS(vdev->msix->entries) * sizeof(unsigned long)); - ret =3D msix_init(&vdev->pdev, vdev->msix->entries, - vdev->bars[vdev->msix->table_bar].region.mem, - vdev->msix->table_bar, vdev->msix->table_offset, - vdev->bars[vdev->msix->pba_bar].region.mem, - vdev->msix->pba_bar, vdev->msix->pba_offset, pos, - &err); + ret =3D msix_validate_and_init(&vdev->pdev, vdev->msix->entries, + vdev->bars[vdev->msix->table_bar].region.mem, + vdev->msix->table_bar, vdev->msix->table_offs= et, + vdev->bars[vdev->msix->pba_bar].region.mem, + vdev->msix->pba_bar, vdev->msix->pba_offset, = pos, + &err); if (ret < 0) { if (ret =3D=3D -ENOTSUP) { error_report_err(err); diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h index 1f27658d352f..815e59bc96f3 100644 --- a/include/hw/pci/msix.h +++ b/include/hw/pci/msix.h @@ -11,6 +11,11 @@ int msix_init(PCIDevice *dev, unsigned short nentries, unsigned table_offset, MemoryRegion *pba_bar, uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos, Error **errp); +int msix_validate_and_init(PCIDevice *dev, unsigned short nentries, + MemoryRegion *table_bar, uint8_t table_bar_nr, + unsigned table_offset, MemoryRegion *pba_bar, + uint8_t pba_bar_nr, unsigned pba_offset, + uint8_t cap_pos, Error **errp); int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries, uint8_t bar_nr, Error **errp); =20 --=20 2.1.0 From nobody Wed May 8 22:26:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488010893661605.8025508422239; Sat, 25 Feb 2017 00:21:33 -0800 (PST) Received: from localhost ([::1]:41729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXbf-0002QS-4j for importer@patchew.org; Sat, 25 Feb 2017 03:21:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa1-0001VU-BK for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chXZz-0008TF-Ok for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:49 -0500 Received: from [59.151.112.132] (port=44237 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXZz-0008OA-26 for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:47 -0500 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Feb 2017 16:19:19 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 3AEE247C4EAF; Sat, 25 Feb 2017 16:19:19 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 25 Feb 2017 16:19:18 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15950438" From: Cao jin To: Date: Sat, 25 Feb 2017 16:26:36 +0800 Message-ID: <1488011202-32121-3-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: 3AEE247C4EAF.AE526 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v10 2/8] megasas: change behaviour of msix switch X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Paolo Bonzini , Hannes Reinecke , Markus Armbruster , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Resolve the TODO, msix=3Dauto means msix on; if user specify msix=3Don, then device creation fail on msix_init failure. Also undo the overwrites of user configuration of msix. CC: Michael S. Tsirkin CC: Hannes Reinecke CC: Paolo Bonzini CC: Markus Armbruster CC: Marcel Apfelbaum Reviewed-by: Markus Armbruster Acked-by: Marcel Apfelbaum Reviewed-by: Hannes Reinecke Signed-off-by: Cao jin --- hw/scsi/megasas.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index e3d59b7c83c7..eab480da354e 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -2359,18 +2359,28 @@ static void megasas_scsi_realize(PCIDevice *dev, Er= ror **errp) =20 memory_region_init_io(&s->mmio_io, OBJECT(s), &megasas_mmio_ops, s, "megasas-mmio", 0x4000); + if (megasas_use_msix(s)) { + ret =3D msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000, + &s->mmio_io, b->mmio_bar, 0x3800, 0x68, &err); + if (ret && s->msix =3D=3D ON_OFF_AUTO_ON) { + /* Can't satisfy user's explicit msix=3Don request, fail */ + error_append_hint(&err, "You have to use msix=3Dauto (default)= or " + "msix=3Doff with this machine type.\n"); + /* No instance_finalize method, need to free the resource here= */ + object_unref(OBJECT(&s->mmio_io)); + error_propagate(errp, err); + return; + } + assert(!err || s->msix =3D=3D ON_OFF_AUTO_AUTO); + /* With msix=3Dauto, we fall back to MSI off silently */ + error_free(err); + } + memory_region_init_io(&s->port_io, OBJECT(s), &megasas_port_ops, s, "megasas-io", 256); memory_region_init_io(&s->queue_io, OBJECT(s), &megasas_queue_ops, s, "megasas-queue", 0x40000); =20 - if (megasas_use_msix(s) && - msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000, - &s->mmio_io, b->mmio_bar, 0x3800, 0x68, NULL)) { - /* TODO: check msix_init's error, and should fail on msix=3Don */ - s->msix =3D ON_OFF_AUTO_OFF; - } - if (pci_is_express(dev)) { pcie_endpoint_cap_init(dev, 0xa0); } --=20 2.1.0 From nobody Wed May 8 22:26:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488010893500888.2535164477717; Sat, 25 Feb 2017 00:21:33 -0800 (PST) Received: from localhost ([::1]:41728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXbf-0002Pc-2A for importer@patchew.org; Sat, 25 Feb 2017 03:21:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa0-0001VQ-Ta for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chXZw-0008Qv-BQ for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:48 -0500 Received: from [59.151.112.132] (port=44237 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXZv-0008OA-LX for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:44 -0500 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Feb 2017 16:19:19 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id C789447C4EB6; Sat, 25 Feb 2017 16:19:19 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 25 Feb 2017 16:19:19 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15950442" From: Cao jin To: Date: Sat, 25 Feb 2017 16:26:37 +0800 Message-ID: <1488011202-32121-4-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: C789447C4EB6.ABEAD X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v10 3/8] hcd-xhci: change behaviour of msix switch X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Markus Armbruster , Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Resolve the TODO, msix=3Dauto means msix on; if user specify msix=3Don, then device creation fail on msix_init failure. CC: Gerd Hoffmann CC: Michael S. Tsirkin CC: Markus Armbruster CC: Marcel Apfelbaum Reviewed-by: Gerd Hoffmann Reviewed-by: Markus Armbruster Acked-by: Marcel Apfelbaum Signed-off-by: Cao jin --- hw/usb/hcd-xhci.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 28dd2f2c9a97..4551a3758b3e 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3554,12 +3554,14 @@ static void usb_xhci_realize(struct PCIDevice *dev,= Error **errp) if (xhci->numintrs < 1) { xhci->numintrs =3D 1; } + if (xhci->numslots > MAXSLOTS) { xhci->numslots =3D MAXSLOTS; } if (xhci->numslots < 1) { xhci->numslots =3D 1; } + if (xhci_get_flag(xhci, XHCI_FLAG_ENABLE_STREAMS)) { xhci->max_pstreams_mask =3D 7; /* =3D=3D 256 primary streams */ } else { @@ -3587,6 +3589,25 @@ static void usb_xhci_realize(struct PCIDevice *dev, = Error **errp) xhci->mfwrap_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, xhci_mfwrap_ti= mer, xhci); =20 memory_region_init(&xhci->mem, OBJECT(xhci), "xhci", LEN_REGS); + if (xhci->msix !=3D ON_OFF_AUTO_OFF) { + ret =3D msix_init(dev, xhci->numintrs, + &xhci->mem, 0, OFF_MSIX_TABLE, + &xhci->mem, 0, OFF_MSIX_PBA, + 0x90, &err); + if (ret && xhci->msix =3D=3D ON_OFF_AUTO_ON) { + /* Can't satisfy user's explicit msix=3Don request, fail */ + error_append_hint(&err, "You have to use msix=3Dauto (default)= or " + "msix=3Doff with this machine type.\n"); + /* No instance_finalize method, need to free the resource here= */ + object_unref(OBJECT(&xhci->mem)); + error_propagate(errp, err); + return; + } + assert(!err || xhci->msix =3D=3D ON_OFF_AUTO_AUTO); + /* With msix=3Dauto, we fall back to MSI off silently */ + error_free(err); + } + memory_region_init_io(&xhci->mem_cap, OBJECT(xhci), &xhci_cap_ops, xhc= i, "capabilities", LEN_CAP); memory_region_init_io(&xhci->mem_oper, OBJECT(xhci), &xhci_oper_ops, x= hci, @@ -3619,14 +3640,6 @@ static void usb_xhci_realize(struct PCIDevice *dev, = Error **errp) ret =3D pcie_endpoint_cap_init(dev, 0xa0); assert(ret >=3D 0); } - - if (xhci->msix !=3D ON_OFF_AUTO_OFF) { - /* TODO check for errors, and should fail when msix=3Don */ - msix_init(dev, xhci->numintrs, - &xhci->mem, 0, OFF_MSIX_TABLE, - &xhci->mem, 0, OFF_MSIX_PBA, - 0x90, NULL); - } } =20 static void usb_xhci_exit(PCIDevice *dev) --=20 2.1.0 From nobody Wed May 8 22:26:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148801110302485.16055734535689; Sat, 25 Feb 2017 00:25:03 -0800 (PST) Received: from localhost ([::1]:41743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXf3-0006LT-LE for importer@patchew.org; Sat, 25 Feb 2017 03:25:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa1-0001VT-A0 for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chXa0-0008Tm-4H for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:49 -0500 Received: from [59.151.112.132] (port=45078 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXZz-0008R1-OS for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:48 -0500 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Feb 2017 16:19:19 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 6024147C4EBC; Sat, 25 Feb 2017 16:19:20 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 25 Feb 2017 16:19:20 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15950441" From: Cao jin To: Date: Sat, 25 Feb 2017 16:26:38 +0800 Message-ID: <1488011202-32121-5-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: 6024147C4EBC.AA6E9 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v10 4/8] megasas: undo the overwrites of msi user configuration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Paolo Bonzini , "Michael S. Tsirkin" , Hannes Reinecke , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit afea4e14 seems forgetting to undo the overwrites, which is unsuitable. CC: Hannes Reinecke CC: Paolo Bonzini CC: Markus Armbruster CC: Marcel Apfelbaum CC: Michael S. Tsirkin Reviewed-by: Markus Armbruster Acked-by: Marcel Apfelbaum Reviewed-by: Hannes Reinecke Signed-off-by: Cao jin --- hw/scsi/megasas.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index eab480da354e..ca98ae7cc329 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -2350,11 +2350,10 @@ static void megasas_scsi_realize(PCIDevice *dev, Er= ror **errp) "msi=3Doff with this machine type.\n"); error_propagate(errp, err); return; - } else if (ret) { - /* With msi=3Dauto, we fall back to MSI off silently */ - s->msi =3D ON_OFF_AUTO_OFF; - error_free(err); } + assert(!err || s->msix =3D=3D ON_OFF_AUTO_AUTO); + /* With msi=3Dauto, we fall back to MSI off silently */ + error_free(err); } =20 memory_region_init_io(&s->mmio_io, OBJECT(s), &megasas_mmio_ops, s, --=20 2.1.0 From nobody Wed May 8 22:26:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488010894749418.92032929471577; Sat, 25 Feb 2017 00:21:34 -0800 (PST) Received: from localhost ([::1]:41731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXbh-0002Sb-F8 for importer@patchew.org; Sat, 25 Feb 2017 03:21:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa1-0001VR-9R for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chXZy-0008SI-9R for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:49 -0500 Received: from [59.151.112.132] (port=44237 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXZx-0008OA-3a for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:46 -0500 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Feb 2017 16:19:19 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id EC7CB47C4EBF; Sat, 25 Feb 2017 16:19:20 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 25 Feb 2017 16:19:20 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15950439" From: Cao jin To: Date: Sat, 25 Feb 2017 16:26:39 +0800 Message-ID: <1488011202-32121-6-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: EC7CB47C4EBF.AF433 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v10 5/8] vmxnet3: fix reference leak issue X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fleytman , Jason Wang , Markus Armbruster , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On migration target, msix_vector_use() will be called in vmxnet3_post_load() in second time, without a matching second call to msi_vector_unuse(), which results in vector reference leak. CC: Dmitry Fleytman CC: Jason Wang CC: Markus Armbruster CC: Michael S. Tsirkin Reviewed-by: Markus Armbruster Reviewed-by: Dmitry Fleytman Acked-by: Marcel Apfelbaum Signed-off-by: Cao jin --- hw/net/vmxnet3.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index e13a798b3b00..81ab131e4a47 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -2556,21 +2556,11 @@ static int vmxnet3_put_rxq_descr(QEMUFile *f, void = *pv, size_t size, static int vmxnet3_post_load(void *opaque, int version_id) { VMXNET3State *s =3D opaque; - PCIDevice *d =3D PCI_DEVICE(s); =20 net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s), s->max_tx_frags, s->peer_has_vhdr); net_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr); =20 - if (s->msix_used) { - if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) { - VMW_WRPRN("Failed to re-use MSI-X vectors"); - msix_uninit(d, &s->msix_bar, &s->msix_bar); - s->msix_used =3D false; - return -1; - } - } - vmxnet3_validate_queues(s); vmxnet3_validate_interrupts(s); =20 --=20 2.1.0 From nobody Wed May 8 22:26:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148801110765885.62624452716113; Sat, 25 Feb 2017 00:25:07 -0800 (PST) Received: from localhost ([::1]:41745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXf8-0006PB-Fr for importer@patchew.org; Sat, 25 Feb 2017 03:25:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa2-0001Va-2P for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chXa0-0008Ty-QZ for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:50 -0500 Received: from [59.151.112.132] (port=8113 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXZz-0008SS-Sd for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:48 -0500 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Feb 2017 16:19:19 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 84F5947D8B60; Sat, 25 Feb 2017 16:19:21 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 25 Feb 2017 16:19:21 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15950443" From: Cao jin To: Date: Sat, 25 Feb 2017 16:26:40 +0800 Message-ID: <1488011202-32121-7-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: 84F5947D8B60.A9CCE X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v10 6/8] vmxnet3: remove unnecessary internal msix flag X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fleytman , Jason Wang , Markus Armbruster , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Internal flag msix_used is unnecessary, it has the same effect as msix_enabled(). The corresponding msi flag is already dropped in commit 1070048e. CC: Dmitry Fleytman CC: Jason Wang CC: Markus Armbruster CC: Michael S. Tsirkin Reviewed-by: Markus Armbruster Reviewed-by: Dmitry Fleytman Acked-by: Marcel Apfelbaum Signed-off-by: Cao jin --- hw/net/vmxnet3.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 81ab131e4a47..a3ed77f04b7c 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -281,8 +281,6 @@ typedef struct { Vmxnet3RxqDescr rxq_descr[VMXNET3_DEVICE_MAX_RX_QUEUES]; Vmxnet3TxqDescr txq_descr[VMXNET3_DEVICE_MAX_TX_QUEUES]; =20 - /* Whether MSI-X support was installed successfully */ - bool msix_used; hwaddr drv_shmem; hwaddr temp_shared_guest_driver_memory; =20 @@ -359,7 +357,7 @@ static bool _vmxnet3_assert_interrupt_line(VMXNET3State= *s, uint32_t int_idx) { PCIDevice *d =3D PCI_DEVICE(s); =20 - if (s->msix_used && msix_enabled(d)) { + if (msix_enabled(d)) { VMW_IRPRN("Sending MSI-X notification for vector %u", int_idx); msix_notify(d, int_idx); return false; @@ -383,7 +381,7 @@ static void _vmxnet3_deassert_interrupt_line(VMXNET3Sta= te *s, int lidx) * This function should never be called for MSI(X) interrupts * because deassertion never required for message interrupts */ - assert(!s->msix_used || !msix_enabled(d)); + assert(!msix_enabled(d)); /* * This function should never be called for MSI(X) interrupts * because deassertion never required for message interrupts @@ -421,7 +419,7 @@ static void vmxnet3_trigger_interrupt(VMXNET3State *s, = int lidx) s->interrupt_states[lidx].is_pending =3D true; vmxnet3_update_interrupt_line_state(s, lidx); =20 - if (s->msix_used && msix_enabled(d) && s->auto_int_masking) { + if (msix_enabled(d) && s->auto_int_masking) { goto do_automask; } =20 @@ -1428,7 +1426,7 @@ static void vmxnet3_update_features(VMXNET3State *s) =20 static bool vmxnet3_verify_intx(VMXNET3State *s, int intx) { - return s->msix_used || msi_enabled(PCI_DEVICE(s)) + return msix_enabled(PCI_DEVICE(s)) || msi_enabled(PCI_DEVICE(s)) || intx =3D=3D pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_P= IN) - 1; } =20 @@ -1445,18 +1443,18 @@ static void vmxnet3_validate_interrupts(VMXNET3Stat= e *s) int i; =20 VMW_CFPRN("Verifying event interrupt index (%d)", s->event_int_idx); - vmxnet3_validate_interrupt_idx(s->msix_used, s->event_int_idx); + vmxnet3_validate_interrupt_idx(msix_enabled(PCI_DEVICE(s)), s->event_i= nt_idx); =20 for (i =3D 0; i < s->txq_num; i++) { int idx =3D s->txq_descr[i].intr_idx; VMW_CFPRN("Verifying TX queue %d interrupt index (%d)", i, idx); - vmxnet3_validate_interrupt_idx(s->msix_used, idx); + vmxnet3_validate_interrupt_idx(msix_enabled(PCI_DEVICE(s)), idx); } =20 for (i =3D 0; i < s->rxq_num; i++) { int idx =3D s->rxq_descr[i].intr_idx; VMW_CFPRN("Verifying RX queue %d interrupt index (%d)", i, idx); - vmxnet3_validate_interrupt_idx(s->msix_used, idx); + vmxnet3_validate_interrupt_idx(msix_enabled(PCI_DEVICE(s)), idx); } } =20 @@ -2185,6 +2183,7 @@ vmxnet3_use_msix_vectors(VMXNET3State *s, int num_vec= tors) static bool vmxnet3_init_msix(VMXNET3State *s) { + bool msix; PCIDevice *d =3D PCI_DEVICE(s); int res =3D msix_init(d, VMXNET3_MAX_INTRS, &s->msix_bar, @@ -2194,18 +2193,19 @@ vmxnet3_init_msix(VMXNET3State *s) VMXNET3_MSIX_OFFSET(s), NULL); =20 if (0 > res) { - VMW_WRPRN("Failed to initialize MSI-X, error %d", res); - s->msix_used =3D false; + VMW_WRPRN("Failed to initialize MSI-X, board's MSI support is brok= en"); + msix =3D false; } else { if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) { VMW_WRPRN("Failed to use MSI-X vectors, error %d", res); msix_uninit(d, &s->msix_bar, &s->msix_bar); - s->msix_used =3D false; + msix =3D false; } else { - s->msix_used =3D true; + msix =3D true; } } - return s->msix_used; + + return msix; } =20 static void @@ -2213,7 +2213,7 @@ vmxnet3_cleanup_msix(VMXNET3State *s) { PCIDevice *d =3D PCI_DEVICE(s); =20 - if (s->msix_used) { + if (msix_enabled(d)) { vmxnet3_unuse_msix_vectors(s, VMXNET3_MAX_INTRS); msix_uninit(d, &s->msix_bar, &s->msix_bar); } --=20 2.1.0 From nobody Wed May 8 22:26:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488011442689286.2388261514327; Sat, 25 Feb 2017 00:30:42 -0800 (PST) Received: from localhost ([::1]:41776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXkX-0003Yi-5v for importer@patchew.org; Sat, 25 Feb 2017 03:30:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa2-0001Vg-7q for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chXa1-0008UM-CQ for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:50 -0500 Received: from [59.151.112.132] (port=45078 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa0-0008R1-Tv for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:49 -0500 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Feb 2017 16:19:24 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 2942247C4E82; Sat, 25 Feb 2017 16:19:22 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 25 Feb 2017 16:19:21 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15950445" From: Cao jin To: Date: Sat, 25 Feb 2017 16:26:41 +0800 Message-ID: <1488011202-32121-8-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: 2942247C4E82.A9245 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v10 7/8] msi_init: convert assert to return -errno X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Markus Armbruster , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" According to the disscussion: http://lists.nongnu.org/archive/html/qemu-devel/2016-09/msg08215.html Let leaf function returns reasonable -errno, let caller decide how to handle the return value. Suggested-by: Markus Armbruster CC: Markus Armbruster CC: Michael S. Tsirkin CC: Marcel Apfelbaum Reviewed-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum Signed-off-by: Cao jin --- hw/pci/msi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/pci/msi.c b/hw/pci/msi.c index a87b2278a373..af3efbe525ce 100644 --- a/hw/pci/msi.c +++ b/hw/pci/msi.c @@ -201,9 +201,12 @@ int msi_init(struct PCIDevice *dev, uint8_t offset, " 64bit %d mask %d\n", offset, nr_vectors, msi64bit, msi_per_vector_mask); =20 - assert(!(nr_vectors & (nr_vectors - 1))); /* power of 2 */ - assert(nr_vectors > 0); - assert(nr_vectors <=3D PCI_MSI_VECTORS_MAX); + /* vector sanity test: should in range 1 - 32, should be power of 2 */ + if (!is_power_of_2(nr_vectors) || nr_vectors > PCI_MSI_VECTORS_MAX) { + error_setg(errp, "Invalid vector number: %d", nr_vectors); + return -EINVAL; + } + /* the nr of MSI vectors is up to 32 */ vectors_order =3D ctz32(nr_vectors); =20 --=20 2.1.0 From nobody Wed May 8 22:26:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488011304772995.3055366943717; Sat, 25 Feb 2017 00:28:24 -0800 (PST) Received: from localhost ([::1]:41763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXiJ-0001gg-7r for importer@patchew.org; Sat, 25 Feb 2017 03:28:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa2-0001Vr-TN for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chXa1-0008Ul-UL for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:50 -0500 Received: from [59.151.112.132] (port=8113 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chXa1-0008SS-IN for qemu-devel@nongnu.org; Sat, 25 Feb 2017 03:19:49 -0500 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Feb 2017 16:19:24 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id B6F5847C4E9B; Sat, 25 Feb 2017 16:19:22 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 25 Feb 2017 16:19:22 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15950446" From: Cao jin To: Date: Sat, 25 Feb 2017 16:26:42 +0800 Message-ID: <1488011202-32121-9-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1488011202-32121-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: B6F5847C4E9B.ADA7C X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v10 8/8] megasas: remove unnecessary megasas_use_msix() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Paolo Bonzini , "Michael S. Tsirkin" , Hannes Reinecke , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Also move certain hunk above, to place msix init related code together. CC: Hannes Reinecke CC: Paolo Bonzini CC: Markus Armbruster CC: Marcel Apfelbaum CC: Michael S. Tsirkin Reviewed-by: Markus Armbruster Reviewed-by: Hannes Reinecke Signed-off-by: Cao jin --- hw/scsi/megasas.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index ca98ae7cc329..49f38002448e 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -155,11 +155,6 @@ static bool megasas_use_queue64(MegasasState *s) return s->flags & MEGASAS_MASK_USE_QUEUE64; } =20 -static bool megasas_use_msix(MegasasState *s) -{ - return s->msix !=3D ON_OFF_AUTO_OFF; -} - static bool megasas_is_jbod(MegasasState *s) { return s->flags & MEGASAS_MASK_USE_JBOD; @@ -2306,9 +2301,7 @@ static void megasas_scsi_uninit(PCIDevice *d) { MegasasState *s =3D MEGASAS(d); =20 - if (megasas_use_msix(s)) { - msix_uninit(d, &s->mmio_io, &s->mmio_io); - } + msix_uninit(d, &s->mmio_io, &s->mmio_io); msi_uninit(d); } =20 @@ -2358,7 +2351,7 @@ static void megasas_scsi_realize(PCIDevice *dev, Erro= r **errp) =20 memory_region_init_io(&s->mmio_io, OBJECT(s), &megasas_mmio_ops, s, "megasas-mmio", 0x4000); - if (megasas_use_msix(s)) { + if (s->msix !=3D ON_OFF_AUTO_OFF) { ret =3D msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000, &s->mmio_io, b->mmio_bar, 0x3800, 0x68, &err); if (ret && s->msix =3D=3D ON_OFF_AUTO_ON) { @@ -2375,6 +2368,10 @@ static void megasas_scsi_realize(PCIDevice *dev, Err= or **errp) error_free(err); } =20 + if (s->msix !=3D ON_OFF_AUTO_OFF) { + msix_vector_use(dev, 0); + } + memory_region_init_io(&s->port_io, OBJECT(s), &megasas_port_ops, s, "megasas-io", 256); memory_region_init_io(&s->queue_io, OBJECT(s), &megasas_queue_ops, s, @@ -2390,10 +2387,6 @@ static void megasas_scsi_realize(PCIDevice *dev, Err= or **errp) pci_register_bar(dev, b->mmio_bar, bar_type, &s->mmio_io); pci_register_bar(dev, 3, bar_type, &s->queue_io); =20 - if (megasas_use_msix(s)) { - msix_vector_use(dev, 0); - } - s->fw_state =3D MFI_FWSTATE_READY; if (!s->sas_addr) { s->sas_addr =3D ((NAA_LOCALLY_ASSIGNED_ID << 24) | --=20 2.1.0