From patchwork Tue Oct 30 05:18:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10660459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7B1613BF for ; Tue, 30 Oct 2018 05:20:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C686029A86 for ; Tue, 30 Oct 2018 05:20:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BACE929AA0; Tue, 30 Oct 2018 05:20:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6CDEA29A86 for ; Tue, 30 Oct 2018 05:20:31 +0000 (UTC) Received: from localhost ([::1]:50833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMS6-0006vB-2Z for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 01:20:30 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMQa-0005hC-I6 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:18:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHMQZ-0005R4-VH for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:18:56 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:37595) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHMQY-0005Pn-HE; Tue, 30 Oct 2018 01:18:54 -0400 Received: by mail-pg1-x543.google.com with SMTP id c10-v6so5036629pgq.4; Mon, 29 Oct 2018 22:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FgvdVDUPnI673cSBmsDUsU/PAy+GUv8Lfar0Uhzqfac=; b=QLypHxday00TqgR7oyx5lNeyzithv4BdXW+X+bE0ZKuBiuQ1epMn/wun33W9pljhev Sclt+JM0WwqKnc6A/ca0sKjWA4z5L46zCPk5ofL5Ll9CKLXc5AWSly811tPHC9Al3Rqr bgRmXcsA591QJllS96YreWeg0zEeRnK5Vn+xTXFwIWwywLxKr5HwYwUIui3JvR0FqwND bsbg4y0qX8eT9ZyZbhdPAtAT+xD2TmfC/aYIY1P1TVwatC/eZMmLqD4dYXyKM3TU6FVc 3azQn97DnyvrRSsMHQ/UHr8Um5DZZcdOmlzgpeSnKc8HybWSKiYT1J3y/6BhzeQUoDoq eWNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FgvdVDUPnI673cSBmsDUsU/PAy+GUv8Lfar0Uhzqfac=; b=YS9UrCQusimqaypy3xXgOeWDlI3IchLGeJAZoS2lTjeSBEvwNFSorm4moI6H0d+y8m jabUE6QTpTklHF6VkW93BQi0tvgfOrQtI0hSWq75jau67/oVhEX87vZN2t369cXXAMKa +dtkOmgRvS2Kb60H/BMMwQitXHcY1o8j3O7M1Qduy8CcJXgx2zp/bmnweJ0CbjLaqq1M WZZbiNoNZtSiTsjOqzCGJDkoCBIC5pRp+2F0/dlkhq0Tx6dNOkuim4z1ChYct4WWOKCH T1cXmx8XjKuQ8/yZeySY3rRXLUNdD/WHq4bPtth/DRIgyzJLbZH5zRJkK3QR7qKAVDIN MnqA== X-Gm-Message-State: AGRZ1gLesHU3i7pzgCo36jax7Bfzo8h/B18xDMnJLJW6N1gibOqBL7nF PberwzKRq9YwQ+EaXScusJo= X-Google-Smtp-Source: AJdET5d47HxehRDXZU6qZ2NTCglyanSjlXSxRHwqP3d8/pBbTIbGBiP1nZcBjKzkmMEBbL5he+offQ== X-Received: by 2002:a63:9a09:: with SMTP id o9mr15012274pge.94.1540876733700; Mon, 29 Oct 2018 22:18:53 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.65]) by smtp.gmail.com with ESMTPSA id p129-v6sm11463729pgp.92.2018.10.29.22.18.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 22:18:53 -0700 (PDT) From: Li Qiang To: keith.busch@intel.com, kwolf@redhat.com, mreitz@redhat.com Date: Mon, 29 Oct 2018 22:18:37 -0700 Message-Id: <1540876720-9574-2-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> References: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH 1/4] nvme: use TYPE_NVME instead of constant string 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: Li Qiang , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Li Qiang Reviewed-by: Max Reitz --- hw/block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index fc7dacb..676cc48 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1379,7 +1379,7 @@ static void nvme_instance_init(Object *obj) } static const TypeInfo nvme_info = { - .name = "nvme", + .name = TYPE_NVME, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(NvmeCtrl), .class_init = nvme_class_init, From patchwork Tue Oct 30 05:18:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10660461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A923413A4 for ; Tue, 30 Oct 2018 05:20:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96EED29A86 for ; Tue, 30 Oct 2018 05:20:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87B8729AAF; Tue, 30 Oct 2018 05:20:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2383429A86 for ; Tue, 30 Oct 2018 05:20:40 +0000 (UTC) Received: from localhost ([::1]:50834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMSF-00072a-Bf for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 01:20:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMQi-0005lz-UV for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:19:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHMQi-0005V8-3q for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:19:04 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:42898) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHMQb-0005Rm-VV; Tue, 30 Oct 2018 01:18:58 -0400 Received: by mail-pf1-x444.google.com with SMTP id f26-v6so5191983pfn.9; Mon, 29 Oct 2018 22:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q5ERHq/GYs6jQbpyqrBOwyNWI53cjm9LZQoHpww6Txw=; b=qnO8Y/d0SJVwVLYnflkv8fUeWnSzBKV7osgAyq6HNnxE6BX5nlYKdPP2fYpnerZFkT QVuMP4ALrnsEMjj9KAuAotURifYW3bEWegS4jIzSDzWKXqYYI6Nc0Zf9QNyKgZ691bC4 pzWvgbgpqGNNgVvHCn0vAvV+0v+d6PnCHGaXK0WWsR3/7my1+oknef9zCFE3HBswqtPq LXCIRfIvphAxfKGso1dyR4mipQxJhNqFblHKKRgRSUH+/UgzI9eqFYdRmdmRmhkl2InR 0igCzGvU2lRtiI/jTGExPzmfUoZoKWg5axZYL2Us/kmCIbv2dGgPkAxa1OhuA0K5t8ct ao3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q5ERHq/GYs6jQbpyqrBOwyNWI53cjm9LZQoHpww6Txw=; b=DqV1gIwswFQj0o8SRUhQx0/NBX6ZRPO+R5UXz6XMj2/6JZmUsM8b27CZrDx31y6/dX J2JBtu/6C599h00BJIP0dfQOw7s5fV+ZmCsUhNEjsrr0KIoTcgf1SSIVgcdCisk3ulqb m23pJI+2ifFXHEX1X27CMmIiX0f92Q/PYG2V3UU142rqpifuKOEyEb/T7eo57jrvp1g+ ViJjTLRZTZ3T7l75GvFik1R3c1WDPRyaK6c9MCnBQxRYlE5xM4LIxqVUOrsbYuRSP/An p6HchURZhkUEMhy+wWo26L1QTK04vbRdKfx0BytKutb2yg4fabAOeFA04mOUMOhknK7j aYvQ== X-Gm-Message-State: AGRZ1gJ91ktZiW+CbAb3upYXpQIvzszIPAhQAaTN2NpvJKSJ20c3tV1a OYMk2vsMmPx3IU7lUceoWoY= X-Google-Smtp-Source: AJdET5fzcyAHaq6eMYbR2v+YUicJEdn7/dBy8fRbzaFiT0EQ6woOPKu+umP1YM+Ul8nhBCEdzKwltw== X-Received: by 2002:a62:388b:: with SMTP id f133-v6mr1484333pfa.48.1540876737081; Mon, 29 Oct 2018 22:18:57 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.65]) by smtp.gmail.com with ESMTPSA id p129-v6sm11463729pgp.92.2018.10.29.22.18.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 22:18:56 -0700 (PDT) From: Li Qiang To: keith.busch@intel.com, kwolf@redhat.com, mreitz@redhat.com Date: Mon, 29 Oct 2018 22:18:38 -0700 Message-Id: <1540876720-9574-3-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> References: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH 2/4] nvme: ensure the num_queues is not zero 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: Li Qiang , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When it is zero, it causes segv. Backtrack: Thread 5 "qemu-system-x86" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffc6c17700 (LWP 51808)] 0x0000555555acbd90 in nvme_start_ctrl (n=0x6240000c8100) at hw/block/nvme.c:820 warning: Source file is more recent than executable. 820 if (unlikely(n->cq[0])) { (gdb) bt 0 0x0000555555acbd90 in nvme_start_ctrl (n=0x6240000c8100) at hw/block/nvme.c:820 1 0x0000555555accdbc in nvme_write_bar (n=0x6240000c8100, offset=20, data=4587521, size=4) at hw/block/nvme.c:964 2 0x0000555555acdd2b in nvme_mmio_write (opaque=0x6240000c8100, addr=20, data=4587521, size=4) at hw/block/nvme.c:1158 3 0x00005555558973ed in memory_region_write_accessor (mr=0x6240000c89e0, addr=20, value=0x7fffc6c14428, size=4, shift=0, mask=4294967295, attrs=...) at /home/liqiang02/qemu-upstream/qemu/memory.c:500 4 0x0000555555897600 in access_with_adjusted_size (addr=20, value=0x7fffc6c14428, size=4, access_size_min=2, access_size_max=8, access_fn=0x555555897304 , mr=0x6240000c89e0, attrs=...) at /home/liqiang02/qemu-upstream/qemu/memory.c:566 5 0x000055555589a200 in memory_region_dispatch_write (mr=0x6240000c89e0, addr=20, data=4587521, size=4, attrs=...) at /home/liqiang02/qemu-upstream/qemu/memory.c:1442 6 0x0000555555835151 in flatview_write_continue (fv=0x6060000e6fc0, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4, addr1=20, l=4, mr=0x6240000c89e0) at /home/liqiang02/qemu-upstream/qemu/exec.c:3233 7 0x000055555583529b in flatview_write (fv=0x6060000e6fc0, addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4) at /home/liqiang02/qemu-upstream/qemu/exec.c:3272 8 0x00005555558355a1 in address_space_write (as=0x55555683ade0 , addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4) at /home/liqiang02/qemu-upstream/qemu/exec.c:3362 9 0x00005555558355f2 in address_space_rw (as=0x55555683ade0 , addr=4273930260, attrs=..., buf=0x7fffc8a18028 "\001", len=4, is_write=true) at /home/liqiang02/qemu-upstream/qemu/exec.c:3373 10 0x00005555558b66ac in kvm_cpu_exec (cpu=0x631000014800) at /home/liqiang02/qemu-upstream/qemu/accel/kvm/kvm-all.c:2031 11 0x000055555587c3ac in qemu_kvm_cpu_thread_fn (arg=0x631000014800) at /home/liqiang02/qemu-upstream/qemu/cpus.c:1277 12 0x0000555555e54ae6 in qemu_thread_start (args=0x60300002c170) at util/qemu-thread-posix.c:504 13 0x00007fffdadbd494 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 14 0x00007fffdaaffacf in clone () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) q Signed-off-by: Li Qiang --- hw/block/nvme.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 676cc48..72c9644 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1221,6 +1221,10 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) error_setg(errp, "serial property not set"); return; } + + if (!n->num_queues) { + error_setg(errp, "num_queues can't be zero"); + } blkconf_blocksizes(&n->conf); if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), false, errp)) { From patchwork Tue Oct 30 05:18:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10660465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60FDA13A4 for ; Tue, 30 Oct 2018 05:20:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 505C829A86 for ; Tue, 30 Oct 2018 05:20:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44B0B29AAF; Tue, 30 Oct 2018 05:20:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EC05129A86 for ; Tue, 30 Oct 2018 05:20:48 +0000 (UTC) Received: from localhost ([::1]:50836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMSO-00078z-6k for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 01:20:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMQj-0005m6-1T for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:19:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHMQi-0005VU-Gi for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:19:05 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:34595) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHMQg-0005UL-Pa; Tue, 30 Oct 2018 01:19:02 -0400 Received: by mail-pg1-x542.google.com with SMTP id k1-v6so3613895pgq.1; Mon, 29 Oct 2018 22:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dDSmHb1A+FJOTrF4tNqJjuWnld7W94TYD1FzcZrObgY=; b=OrBNQH3g7HhWNyB8M1vKx7N3Z8SApBp8mls7tfuyHrnBFa97FxWmVByqaP057dEOO2 K6p8Yc9zy7mqFnhVh0l55SYao03fHCUjUNLbO3l4LZ9vyEbiKZuIUnjWj/A02wA+Qoil XmnHmb6Y0U60Xgf9cNeT0RLqBGav41O6cl9duPosKHRieDVFzS5QNKbR7T4B0xVuOJUN /33/Zh+wG4jBFqWpv2Tb8czGa5siqjb5KQtZmiNdiannL9+FlR7WjVh2NvkY8A2p0eNU hIhguVvnQR/SjhCFJNoiY8ZMeLtbdKLNq/+WdvqlncKgnSv8wdaUFb7geP8u1M+T+QOd S2zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dDSmHb1A+FJOTrF4tNqJjuWnld7W94TYD1FzcZrObgY=; b=sNCDSWkCu+0qXIlr4GKX97deHbnz+NpGdQBb3xoNPuZqZx+dSqUAYU6ovPgQ4QKXgM HLDv6qO5Wqvm+9wYDShHwedG1VJXAf3lv4da5c8EF6kWDV45yByMIgNuF7FVoSe5KvbB w9sj+FzfA/iAs4b5AUJ5KGbwo3R1fbUTxC0bzQWceAEbBTWpD3SbQX0LjJzvaDGZ6R2X w1JQn/tE0X5+BwqPfKfDDR51dLdC6DxpVxFWJqJGvRhCmKSFSPUpACvoi0sJbI7/e0He +hqAKWlGU2TcTrC5M3jxLbbljN0WmuHoxm4osls+e35QNNI+C0dGbMslD0GDFm4NwQeX FZzg== X-Gm-Message-State: AGRZ1gJ/qTLM2R802niM7m4PZM35hq89JTwxtYGxTAO5na5i8KGHenEp GzgVXocUhMR4k8VceWEvoUs= X-Google-Smtp-Source: AJdET5d5kgkjbCW4mpdAeDkOIc+kiCLkM1PyFrJWZRCtmGPWzHJqowR5nDOyp6GhtgKWMubCFd298A== X-Received: by 2002:a62:7982:: with SMTP id u124-v6mr1418273pfc.95.1540876741952; Mon, 29 Oct 2018 22:19:01 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.65]) by smtp.gmail.com with ESMTPSA id p129-v6sm11463729pgp.92.2018.10.29.22.18.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 22:19:01 -0700 (PDT) From: Li Qiang To: keith.busch@intel.com, kwolf@redhat.com, mreitz@redhat.com Date: Mon, 29 Oct 2018 22:18:39 -0700 Message-Id: <1540876720-9574-4-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> References: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH 3/4] nvme: check msix_init_exclusive_bar return value 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: Li Qiang , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP As this function can fail. Signed-off-by: Li Qiang --- hw/block/nvme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 72c9644..a406c23 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1250,7 +1250,10 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) pci_register_bar(&n->parent_obj, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &n->iomem); - msix_init_exclusive_bar(&n->parent_obj, n->num_queues, 4, NULL); + if (msix_init_exclusive_bar(&n->parent_obj, n->num_queues, 4, NULL)) { + error_setg(errp, "msix_init_exclusive_bar failed"); + return; + } id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID)); id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID)); From patchwork Tue Oct 30 05:18:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10660467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC37C13A4 for ; Tue, 30 Oct 2018 05:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A224F2975D for ; Tue, 30 Oct 2018 05:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9602029AA0; Tue, 30 Oct 2018 05:23:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 46A692975D for ; Tue, 30 Oct 2018 05:23:01 +0000 (UTC) Received: from localhost ([::1]:50850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMUW-0002Nm-LA for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 01:23:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHMQt-0005wR-Ml for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:19:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHMQt-0005jb-1J for qemu-devel@nongnu.org; Tue, 30 Oct 2018 01:19:15 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:37748) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHMQm-0005Yp-3X; Tue, 30 Oct 2018 01:19:08 -0400 Received: by mail-pl1-x641.google.com with SMTP id bh10-v6so4930754plb.4; Mon, 29 Oct 2018 22:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/yalKYo8QkxKhV0bGxdENxR9rF1fleJZX+Sx45kjEoE=; b=lr2GYoc+0J0tE1eGA+Ibi3ovuXDRbsZYPmekJB5J1mcOaLIhoyYKPs195kKhDrWCXF 2gLFNNyacfUokgQmNiOJ8rYXAVCo14nGsNlqIn6k9U/NqLX2DJNAgyHgz1VXd+ZNLd/h k59d9TM+BYiZh72+SsCDwwHdOLOQT/iieLvUCGVfn8Xybn8B4rmHorDU247eSu/Im4bd jN1JWMeelyj2SSJuvnr83uriCQ+eM55g23hPqdy43+34+m9+EWzXcu0x/Wb1GN181CFU 0jzVWaMnKSxELL5+HGPrGcMAxC14oQsXX7vHXmtGWrYYkE4tWtuU1CzXvv5BZCajZO6N E+0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/yalKYo8QkxKhV0bGxdENxR9rF1fleJZX+Sx45kjEoE=; b=jYqN3BfcqjHFA/RlNKwi4qGcR9BVTy+Cow4YKmsbI0umh2EWTE5XvBkQWwean5W2jG fc/3gdiM3WSYJkgTgpOwDZoBL+2ee/wXq8rXic/O9Y8nzZ08oWt+McVjRL5cELfXnlFO 4ESYri/wNvm/h3lRRK1DtSSlVX7A+KHGlq9ogRFyvaFeiunNvzjz0hwSh8Z/VmLaZeLh Uvfyk6kqnkXA5neuEGJiwZo1FkAK83JsWPmls7yv1Adv49E7WVzFwM2+vZCQqepONQYA Jjl7AaPfF+qBsOhbB1MCKyP3mZ38jo63VdS+O7SF/iVT+ce019mtBf7ebVR7zYKtcCoM jNLA== X-Gm-Message-State: AGRZ1gIYJMpF1ht+GFqGPT+x34tpN6nPbn/XQNd5pYV2KZFJm6m0Z68Y yoSvBAouxdneAP0PueIFj7/CZJGHUwE= X-Google-Smtp-Source: AJdET5cT5qkbf/StqJmXu3jUdewHUOIL/JS9r3uoNNL2AbE4wXQhQaoL6Z98NC4IXZenM/Ub3Ingmg== X-Received: by 2002:a17:902:f83:: with SMTP id 3-v6mr10079100plz.254.1540876747354; Mon, 29 Oct 2018 22:19:07 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.65]) by smtp.gmail.com with ESMTPSA id p129-v6sm11463729pgp.92.2018.10.29.22.19.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 22:19:06 -0700 (PDT) From: Li Qiang To: keith.busch@intel.com, kwolf@redhat.com, mreitz@redhat.com Date: Mon, 29 Oct 2018 22:18:40 -0700 Message-Id: <1540876720-9574-5-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> References: <1540876720-9574-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH 4/4] nvme: use pci_dev directly in nvme_realize 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: Li Qiang , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP There is no need to make another reference. Signed-off-by: Li Qiang Reviewed-by: Max Reitz --- hw/block/nvme.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index a406c23..f63e344 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1235,7 +1235,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) pci_conf[PCI_INTERRUPT_PIN] = 1; pci_config_set_prog_interface(pci_dev->config, 0x2); pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS); - pcie_endpoint_cap_init(&n->parent_obj, 0x80); + pcie_endpoint_cap_init(pci_dev, 0x80); n->num_namespaces = 1; n->reg_size = pow2ceil(0x1004 + 2 * (n->num_queues + 1) * 4); @@ -1247,10 +1247,10 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, "nvme", n->reg_size); - pci_register_bar(&n->parent_obj, 0, + pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &n->iomem); - if (msix_init_exclusive_bar(&n->parent_obj, n->num_queues, 4, NULL)) { + if (msix_init_exclusive_bar(pci_dev, n->num_queues, 4, NULL)) { error_setg(errp, "msix_init_exclusive_bar failed"); return; } @@ -1308,7 +1308,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) n->cmbuf = g_malloc0(NVME_CMBSZ_GETSIZE(n->bar.cmbsz)); memory_region_init_io(&n->ctrl_mem, OBJECT(n), &nvme_cmb_ops, n, "nvme-cmb", NVME_CMBSZ_GETSIZE(n->bar.cmbsz)); - pci_register_bar(&n->parent_obj, NVME_CMBLOC_BIR(n->bar.cmbloc), + pci_register_bar(pci_dev, NVME_CMBLOC_BIR(n->bar.cmbloc), PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64 | PCI_BASE_ADDRESS_MEM_PREFETCH, &n->ctrl_mem);