From patchwork Thu Jun 25 18:48:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50AF3C433DF for ; Thu, 25 Jun 2020 18:52:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17EC8206BE for ; Thu, 25 Jun 2020 18:52:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="K5vjhlRU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17EC8206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joWyt-0004GH-C6 for qemu-devel@archiver.kernel.org; Thu, 25 Jun 2020 14:52:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWvc-0007ds-8j for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:48:52 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:35649 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joWva-0000uK-Ow for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:48:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n++iKDu2XPmmW15plWQ8LpzZ4HXc4YUB4AbgsZmqpcg=; b=K5vjhlRUrVBKEVBssn5/OawdnaxMgtGwe8H2jHzGjOUuGLXWcOvAjqyXJ6eMNqMVkSwVkD SuR6QqnzbzBOoGegmGhAQzZ+hlazx68EZn5JQ0GFZB38oeAsDZhhVKOlPy1ZcxFSTlYT8X Bd2n0mOujnb1YwK59ikYcUvcyi/Ai6Y= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-Flv67x9iMY6eBNKeH7XmyA-1; Thu, 25 Jun 2020 14:48:46 -0400 X-MC-Unique: Flv67x9iMY6eBNKeH7XmyA-1 Received: by mail-wm1-f72.google.com with SMTP id t18so7977293wmj.5 for ; Thu, 25 Jun 2020 11:48:46 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=n++iKDu2XPmmW15plWQ8LpzZ4HXc4YUB4AbgsZmqpcg=; b=I1vrV5Ita2twDXpY4ImWdcgfDJSH/I05kDcRQV2IwbTGwzzwX8wzrwbBIw2767g0jy 5Lly2kTLG87HZ0TIFkXyHE3/cn69CLOnYMBXmz5sCfFx5sMZwMZky2Hii0a4UufzEILQ 3HYEg7pDWTfYbTeuVbzexgF57t1W3FBzuVGLyMzkKpjR4TXeSHNZxAnHjp8DWvZwLRon lsmKk8iBV3K2cfNlkhawfc4RMD3sSws4JDZRfChGiatAgB9QGHLwo/a/tFycDk8x46wz 9gZyjt9uvCGnEeEmj7wfXP1SKyMWkqeXEf0Ei7/xDxRCbWbIVcXYbDVR6RpSLjKWHmVm 06RA== X-Gm-Message-State: AOAM530HMSf2qMwjfz4NzjiDlDB1sqPD7elziGoHfX4LochBLOUelWPp mRtgw0RT1JNjNTSO2X96wZy4MQaQJq1+WJbVc3VQi4w94clB/9a6Awzl/VCmnKf4vK/QxH61mJo HHfH6ZJCy3lWcwUk= X-Received: by 2002:a1c:c908:: with SMTP id f8mr4952654wmb.150.1593110925476; Thu, 25 Jun 2020 11:48:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzUPqhXLHIH7O2Xge4yU5cRPBuBUGfQvd8msCxd589G/0uY0Tj9oZBm+7cKPCrmrGd5VwQeQ== X-Received: by 2002:a1c:c908:: with SMTP id f8mr4952634wmb.150.1593110925222; Thu, 25 Jun 2020 11:48:45 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id c17sm11192390wmd.10.2020.06.25.11.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:48:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 01/17] block/nvme: Avoid further processing if trace event not enabled Date: Thu, 25 Jun 2020 20:48:22 +0200 Message-Id: <20200625184838.28172-2-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625184838.28172-1-philmd@redhat.com> References: <20200625184838.28172-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Maxim Levitsky , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Avoid further processing if TRACE_NVME_SUBMIT_COMMAND_RAW is not enabled. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index eb2f54dd9d..1e5b40f61c 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -367,6 +367,9 @@ static void nvme_trace_command(const NvmeCmd *cmd) { int i; + if (!trace_event_get_state_backends(TRACE_NVME_SUBMIT_COMMAND_RAW)) { + return; + } for (i = 0; i < 8; ++i) { uint8_t *cmdp = (uint8_t *)cmd + i * 8; trace_nvme_submit_command_raw(cmdp[0], cmdp[1], cmdp[2], cmdp[3], From patchwork Thu Jun 25 18:48:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF011C433E0 for ; Thu, 25 Jun 2020 18:54:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 95BF1206BE for ; Thu, 25 Jun 2020 18:54:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="doMsI7QA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95BF1206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX0g-0007d6-Rd for qemu-devel@archiver.kernel.org; Thu, 25 Jun 2020 14:54:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWvf-0007iS-QQ for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:48:55 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:39266 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joWve-0000vF-3F for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:48:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vQ6c0CyjjoCdHr4XROOCTHk87bmAQz91kRF02NzcbuY=; b=doMsI7QAPkM2ccU+wa5EFLC9b1SA6yDgDkZT9V8sZ1v9cnSc2cGRKJqX0i64AGo/a+uACM B+1qNVGEJlq8t5S0uC614zoGKcm+6wOyX0LXc1qFOW/T0CqpsggzVL+GdaiS3hoMFfLZUb xfKmHb4cqUvFKo+4TEvqnahNrOtdQP0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-243-R91-rndePDWreOKgZe0T6g-1; Thu, 25 Jun 2020 14:48:51 -0400 X-MC-Unique: R91-rndePDWreOKgZe0T6g-1 Received: by mail-wr1-f71.google.com with SMTP id d6so7725507wrn.1 for ; Thu, 25 Jun 2020 11:48:51 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=vQ6c0CyjjoCdHr4XROOCTHk87bmAQz91kRF02NzcbuY=; b=pp97AAnfF1qDzvm+bVq1jBPbyHjKguuUq0fjU5rgK6RTAyhWQvL+N4DlV3dIeb9Oxv 70TqWgLaTjPu5WdqF7hbWm7ULOHKG7sSX6Ph3eFRcKU5FZ83fvpIA7On8fKaFzq6dz7B KYNcO2R98oPf2+hmZvdpxwbakpRUQZqXIIZ5HvjALjO6i5B5CHyrhcbKN1sBcfVK/SHM siuSHGjLXDA57xNeWJ7GkbZeuWlb7x7sIFjcLCs45MXB7n89SRexQoFEjLYl5Whl7f7m V55XCuUFUjm5P/JNKrZJ3MdgGIRaQwTEMhPe4gRQfIHl4CWQuvz4C+7s3dvjIHkgathJ p35w== X-Gm-Message-State: AOAM531B0gJKyyJP1fIyLIcr3MhgQnijgNJlpBY/jZaHry/mvk4idpBN obrsffFDdpzn+3NOhncE4AF+gxMDG6hYPc4ZDrmaekyespHtaYDJRyMcQqEtKtiJH7n3x0BnAU/ IZkr2y7/0EN9+cVk= X-Received: by 2002:a5d:4b4f:: with SMTP id w15mr16756720wrs.84.1593110930146; Thu, 25 Jun 2020 11:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0SVV+5TXqKTHuoUbKpT5QSyAfugCpdL0rBfSXC1w9+gEwZWxYjC9lHVd6if2zsfwH4LX+wQ== X-Received: by 2002:a5d:4b4f:: with SMTP id w15mr16756704wrs.84.1593110930015; Thu, 25 Jun 2020 11:48:50 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id d201sm13353323wmd.34.2020.06.25.11.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:48:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 02/17] block/nvme: Let nvme_create_queue_pair() fail gracefully Date: Thu, 25 Jun 2020 20:48:23 +0200 Message-Id: <20200625184838.28172-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625184838.28172-1-philmd@redhat.com> References: <20200625184838.28172-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Maxim Levitsky , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" As nvme_create_queue_pair() is allowed to fail, replace the alloc() calls by try_alloc() to avoid aborting QEMU. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 1e5b40f61c..ec0dd21b6e 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -194,13 +194,21 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, int i, r; BDRVNVMeState *s = bs->opaque; Error *local_err = NULL; - NVMeQueuePair *q = g_new0(NVMeQueuePair, 1); + NVMeQueuePair *q; uint64_t prp_list_iova; + q = g_try_new0(NVMeQueuePair, 1); + if (!q) { + return NULL; + } + q->prp_list_pages = qemu_try_blockalign0(bs, + s->page_size * NVME_QUEUE_SIZE); + if (!q->prp_list_pages) { + goto fail; + } qemu_mutex_init(&q->lock); q->index = idx; qemu_co_queue_init(&q->free_req_queue); - q->prp_list_pages = qemu_blockalign0(bs, s->page_size * NVME_QUEUE_SIZE); r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, s->page_size * NVME_QUEUE_SIZE, false, &prp_list_iova); From patchwork Thu Jun 25 18:48:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279418 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F30FEC433E0 for ; Thu, 25 Jun 2020 18:50:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD368206BE for ; Thu, 25 Jun 2020 18:50:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MnxnJhCe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD368206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joWxJ-0001RT-Sk for qemu-devel@archiver.kernel.org; Thu, 25 Jun 2020 14:50:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWvo-0007tj-VY for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27703 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joWvn-0000xL-4e for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=++38kJtX9k0JLhjdquKhWs3mX7Qkr34rNt494GRRank=; b=MnxnJhCePSPwHnn/BaL2L+FGB9FZR3Zjuh2lWQH8AKq+Fdogw1yldZSKOk39CB6zxzK2lk 1VEYSHCfHxsZb4uDw3M0+F/Fh+hipSI/JczRCgQWhPDHbGq9gZpkx7fh6wuuZX4dQI9gBS fn93CSr/Qyuh+svq4r5tVlxgkbV0WSA= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-386-OXyif-SYOayi1UY7olRLBA-1; Thu, 25 Jun 2020 14:49:00 -0400 X-MC-Unique: OXyif-SYOayi1UY7olRLBA-1 Received: by mail-wm1-f69.google.com with SMTP id v6so5725108wmg.1 for ; Thu, 25 Jun 2020 11:49:00 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=++38kJtX9k0JLhjdquKhWs3mX7Qkr34rNt494GRRank=; b=Pjqbg5F7P3izD8HwK440SlhccgrRXA9e/WRwwmSdHqCSMPyK4ie6u8ejxk+co8Iaq2 RJTGLLo9vXSNG6nofTMoDu/k923xEGrqUTw6gJdbDpPpvJde9ndO8665iEXwCuDqAYAP 1k5cvNCOvNyPj5SDGrMvI3xIfZtjH+2fkpxmMYNyNEU3a8dFor9TX0rCKApUiiB216y3 lUz8p6OS8xh8TMU4YEWYPQlXPNZCPpDvWbmNsoadSutHv62F8jriP/7f6eBsDqvZbxVf CToSYccKQqrSyE9JQG69fFVxQcNDw3/fis1DrFIZFXdXDzwTahx2S7vf45LsvaHO51ML maCg== X-Gm-Message-State: AOAM531M2TAx/Pl5E2dHMWzABnIyAFSVuLxG3pcfqMb67Nekefz3Hz7u NlORAAvTyfkbrb+6ABLvWqBCike9XfUQWz9Dhz9qxwRl4Is6FoXstErreRSh1Kxt/HCv8zZCu+k XSSL/N4wktrtdX2g= X-Received: by 2002:a1c:790a:: with SMTP id l10mr4696092wme.80.1593110939415; Thu, 25 Jun 2020 11:48:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiHMQn3r4Gaj/rwVZ+u7W4xq+Xm13Vg31DrBxfxhHFfnjgHPeM3ijP8irZ99+sKkU9/OrSBg== X-Received: by 2002:a1c:790a:: with SMTP id l10mr4696073wme.80.1593110939255; Thu, 25 Jun 2020 11:48:59 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id w2sm22168661wrs.77.2020.06.25.11.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:48:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 04/17] block/nvme: Be explicit we share NvmeIdCtrl / NvmeIdNs structures Date: Thu, 25 Jun 2020 20:48:25 +0200 Message-Id: <20200625184838.28172-5-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625184838.28172-1-philmd@redhat.com> References: <20200625184838.28172-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Maxim Levitsky , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We allocate an unique chunk of memory then use it for two different structures. Introduce the 'idsz_max' variable to hold the maximum size, to make it clearer the size is enough to hold the two structures. Signed-off-by: Philippe Mathieu-Daudé --- FIXME: reword with something that makes more sense... --- block/nvme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 71f8cf27a8..ffda804a8e 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -438,6 +438,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) BDRVNVMeState *s = bs->opaque; NvmeIdCtrl *idctrl; NvmeIdNs *idns; + size_t idsz_max; NvmeLBAF *lbaf; uint8_t *resp; uint16_t oncs; @@ -448,14 +449,15 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) .cdw10 = cpu_to_le32(0x1), }; - resp = qemu_try_blockalign0(bs, sizeof(NvmeIdCtrl)); + idsz_max = MAX_CONST(sizeof(NvmeIdCtrl), sizeof(NvmeIdNs)); + resp = qemu_try_blockalign0(bs, idsz_max); if (!resp) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } idctrl = (NvmeIdCtrl *)resp; idns = (NvmeIdNs *)resp; - r = qemu_vfio_dma_map(s->vfio, resp, sizeof(NvmeIdCtrl), true, &iova); + r = qemu_vfio_dma_map(s->vfio, resp, idsz_max, true, &iova); if (r) { error_setg(errp, "Cannot map buffer for DMA"); goto out; From patchwork Thu Jun 25 18:48:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3061C433DF for ; Thu, 25 Jun 2020 18:56:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C9C4204EA for ; Thu, 25 Jun 2020 18:56:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SoCD7dC+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C9C4204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX2v-0003HA-Uv for qemu-devel@archiver.kernel.org; Thu, 25 Jun 2020 14:56:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWw7-0008Ou-BL for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:23 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40445 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joWw5-00014S-NC for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110961; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IffnAEQwVLooyZqnwMH0USvgIfFSWE7k1J5V8wEsJMc=; b=SoCD7dC+17iEHcRahCbWcYWVcia+C+/6++LYB1bLbVQ7Aj6K3i9DZCc9p6lZBsozxdQeXJ FDO7+nxSyHovvuZo8CkiLo3Tcce7fO3PgkR4UKjNVZDRuvJWNwEOkYVF8h/RkIdF26jNq+ b77H2TTUeyqCZ3VhuFwbAgaZNGLkRz4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-y0XMY1N_O9KAC9e9lsEUXQ-1; Thu, 25 Jun 2020 14:49:19 -0400 X-MC-Unique: y0XMY1N_O9KAC9e9lsEUXQ-1 Received: by mail-wm1-f71.google.com with SMTP id a21so7772797wmd.0 for ; Thu, 25 Jun 2020 11:49:19 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=IffnAEQwVLooyZqnwMH0USvgIfFSWE7k1J5V8wEsJMc=; b=hNNkSwX7HSCtHEB7eNjkCEPX7TycTg25A1xMHfFY580R/yHhmFNjwzzXlbUovX1MIj uEpZMxhiDm8o7ngvqE/K5oryV3bBDSxOnzoVtG3JufFvvQlwho34HfS5w4IMZS0+UU4S gLdvBeNpN4G0er2AUcmu7RnmLo/JzwAlnTLWceDN7ObsCnljhKmgtfnduTARPvGWi95K bR2q6PYeC22LvCwXJF+w7bZlZgEWlqqtbxfT1p6r8gnevXMVbsEiGWd/vwvCCHX822jT xhxmrIm26B8H02lU7hM07vrJUw9MXjddRlLXt8YRQxepJoj1kw9lAeBIgEOInMhMhyzN WKWw== X-Gm-Message-State: AOAM532BBObs92HFK5pfuVOVXEd0YjfuUz8iNXof1TdLeIb607Al34ix kZYck5IV09Tms3hko7hmuWkZcrWUKkr2C/Vy/GYEj37a/NQxmyRBhPpi8UcejIACNEwCzqAxmMi X7cRUSZ186ogTFJE= X-Received: by 2002:adf:9c12:: with SMTP id f18mr41102128wrc.105.1593110958071; Thu, 25 Jun 2020 11:49:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf2A4qmfaAmo1zDhHRG1mrmZJVLhlXeVGijQsIShuyxhNXkhhi8CLFt20HkwC4JskW3cQFMg== X-Received: by 2002:adf:9c12:: with SMTP id f18mr41102109wrc.105.1593110957928; Thu, 25 Jun 2020 11:49:17 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id o1sm34796824wrw.20.2020.06.25.11.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 08/17] block/nvme: Use correct type void* Date: Thu, 25 Jun 2020 20:48:29 +0200 Message-Id: <20200625184838.28172-9-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625184838.28172-1-philmd@redhat.com> References: <20200625184838.28172-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Maxim Levitsky , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" qemu_try_memalign() returns a void*, qemu_vfio_dma_map() consumes a void*. Drop the confusing uint8_t* type. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 1bba496294..095a8ec024 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -441,7 +441,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) NvmeIdNs *idns; size_t idsz_max; NvmeLBAF *lbaf; - uint8_t *resp; + void *resp; uint16_t oncs; int r; uint64_t iova; From patchwork Thu Jun 25 18:48:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279414 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE8CDC433DF for ; Thu, 25 Jun 2020 18:55:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E7D1204EA for ; Thu, 25 Jun 2020 18:55:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eVUceE/g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E7D1204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX1y-0001pS-Mt for qemu-devel@archiver.kernel.org; Thu, 25 Jun 2020 14:55:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWwB-00007Y-VY for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:27 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:30134 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joWwA-00018B-C7 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110965; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yoUDU1XDMhr7CKTebb62prsbDCjR4+uEbV6Q6F/b8bw=; b=eVUceE/gyC+GVzQFowxo2R83i4PsgW9Q9i/Pp2QAGwk8x+pCEK8N0GIzAvsZP3lXnkBwty o21Jy1qmkabQqDBktL0iS2OnoHBkc1zq5/fTvuGfYxruVJjOjNhfG3fWpq/qO875uZoKjy drC9s7jtBoJT8xXnPKN63h4tdTPPsH8= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-LZuUYq87Nae6WQmwDZ_nMQ-1; Thu, 25 Jun 2020 14:49:24 -0400 X-MC-Unique: LZuUYq87Nae6WQmwDZ_nMQ-1 Received: by mail-wm1-f69.google.com with SMTP id g124so7723352wmg.6 for ; Thu, 25 Jun 2020 11:49:23 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=yoUDU1XDMhr7CKTebb62prsbDCjR4+uEbV6Q6F/b8bw=; b=B40vxBYZ+ZpdPTg32qrL3JErQxWmbCEryKLzY7Ujp+tNNKNmcl68LWYrQGyfBm/v/a UW9T7GV6bVAR9FGy/YlGi9/qqVWiGXc5sD4+nA8VPC8LjXtMwzzZF7riogNdTBdlhAyp Xv9eavf0g4UmV02sRqwbPie/fp+vcGQ/KeAvw34z24oP1w/BM7ZHdcbBaut/2+Kng4pf QkUfibTUyFAlsfGmfEsNlyPPFEtEyKqRTA7TkhAPhaspu58MbcyfRZmXFRoeJjmQIHAF tq62yM5Pkt0IPl7crGj6m5fkQr5bFUZlvrgV6zqSgBkeB5zFwIHqTzpGM/ZZaIK9jiEi z50w== X-Gm-Message-State: AOAM533AGn7A/VHohNIRdQbW+9DAHuCFDQckSVPceqqJuAPaIEyuHi9l 6oDRmj4P9nVHC88l73bEuBOuh7qkBLz6SDm3whSMjvBa6nYIEx3wvBv8HIE+SHhZT91A18NIFiC w3pNOUXwSNfG4YLA= X-Received: by 2002:a5d:538e:: with SMTP id d14mr8379355wrv.21.1593110962748; Thu, 25 Jun 2020 11:49:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoU5iUkj0bHZa2q/m94iqBeEZtccFsP/QiM8/PgeLbfW4o5odLxTXnlO9YPKAQkMkk6slJGQ== X-Received: by 2002:a5d:538e:: with SMTP id d14mr8379343wrv.21.1593110962612; Thu, 25 Jun 2020 11:49:22 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id a81sm13905148wmf.30.2020.06.25.11.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 09/17] block/nvme: Remove unused argument from nvme_free_queue_pair() Date: Thu, 25 Jun 2020 20:48:30 +0200 Message-Id: <20200625184838.28172-10-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625184838.28172-1-philmd@redhat.com> References: <20200625184838.28172-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Maxim Levitsky , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_free_queue_pair() doesn't use BlockDriverState, remove it. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 095a8ec024..f87f157dc0 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -170,7 +170,7 @@ static void nvme_init_queue(BlockDriverState *bs, NVMeQueue *q, } } -static void nvme_free_queue_pair(BlockDriverState *bs, NVMeQueuePair *q) +static void nvme_free_queue_pair(NVMeQueuePair *q) { qemu_vfree(q->prp_list_pages); qemu_vfree(q->sq.queue); @@ -241,7 +241,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, return q; fail: - nvme_free_queue_pair(bs, q); + nvme_free_queue_pair(q); return NULL; } @@ -568,7 +568,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) }; if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create io queue [%d]", n); - nvme_free_queue_pair(bs, q); + nvme_free_queue_pair(q); return false; } cmd = (NvmeCmd) { @@ -579,7 +579,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) }; if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create io queue [%d]", n); - nvme_free_queue_pair(bs, q); + nvme_free_queue_pair(q); return false; } s->queues = g_renew(NVMeQueuePair *, s->queues, n + 1); @@ -776,7 +776,7 @@ static void nvme_close(BlockDriverState *bs) BDRVNVMeState *s = bs->opaque; for (i = 0; i < s->nr_queues; ++i) { - nvme_free_queue_pair(bs, s->queues[i]); + nvme_free_queue_pair(s->queues[i]); } g_free(s->queues); aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, From patchwork Thu Jun 25 18:48:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7E53C433E0 for ; Thu, 25 Jun 2020 18:57:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76C6B204EA for ; Thu, 25 Jun 2020 18:57:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GwxrOI0h" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76C6B204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX4P-0005st-Nk for qemu-devel@archiver.kernel.org; Thu, 25 Jun 2020 14:57:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWwI-0000MX-OB for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:34 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:29464 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joWwH-0001C4-3d for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=izV+fRnoW0opUs4fFUxBkpZIhd4njeKjvqFWAFiEQRg=; b=GwxrOI0hvdnyAojoGEwu+mMQ57nV1eTXh8LeeyvT75jDU/OzqqYqjWtdz1AANkIu3yHxCx E5BIFdNDziVznECRNdyp4qw4wn4GItGERga5Bs/xRUud9wNHu4jx+tCiR0bIMqv8wTtaKT ot4q5AXtXAwT7a35Q1i5Yuw81Y9C6+w= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-XJFKTFZAP4invq0XXM3ofw-1; Thu, 25 Jun 2020 14:49:28 -0400 X-MC-Unique: XJFKTFZAP4invq0XXM3ofw-1 Received: by mail-wr1-f69.google.com with SMTP id 59so1077947wrp.4 for ; Thu, 25 Jun 2020 11:49:28 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=izV+fRnoW0opUs4fFUxBkpZIhd4njeKjvqFWAFiEQRg=; b=PQYadaF+omZBuZZnbAXBhf4RiAlGJUxvxB6nIAkflYU2WE8dYiPu+Cpl935P1V6XiO v84Mr6/SS8ivWmgvgELCodSeXp4UGhbgA6H6k8Z09eBw6pPeD9CHYRNQfB75esN/hWhE /bmy3JT+gDDPiJa1jD2HU5LM91mo+YiwADd+cHq+SAigTFk2HoSGrV5Av4mp2+M+4pGk F/558BDfWzm+0S8297hHamoDnO7ycuWRMyTPCbTLX6x49NBFawRLw5mqsUWazorr8Znx cYwIKdMnXLajtIol09lDVyusz+F2k+s1vDPUTIEuIw8y0IRYDVnZYWqtUSzNS5OD1VA6 prvw== X-Gm-Message-State: AOAM532e8gVwVGuLb/8wMmLI2brZZTIhcLqnI/7Kn90b+cznNMCKnzXM SZNBGzAQRnXqf2c9K5TWjJA8IIKYDhORAxbXqNt8gBSz9Zwmo5DdHPedMaY7qFm/VS+PBf9AjrO Yn5z8djZkXbPM1pc= X-Received: by 2002:adf:df10:: with SMTP id y16mr1397294wrl.225.1593110967486; Thu, 25 Jun 2020 11:49:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsPYlJcNfRMt6ytvc3Zunww4+rLme7PDADNfN3PUo5K+rcY2b9DhEMJxwSGoKtG+u2p498cg== X-Received: by 2002:adf:df10:: with SMTP id y16mr1397277wrl.225.1593110967334; Thu, 25 Jun 2020 11:49:27 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id c70sm13236668wme.32.2020.06.25.11.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 10/17] block/nvme: Simplify nvme_init_queue() arguments Date: Thu, 25 Jun 2020 20:48:31 +0200 Message-Id: <20200625184838.28172-11-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625184838.28172-1-philmd@redhat.com> References: <20200625184838.28172-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Maxim Levitsky , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_init_queue() doesn't require BlockDriverState anymore. Replace it by BDRVNVMeState to simplify. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index f87f157dc0..8b6cf4c34b 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -149,10 +149,9 @@ static QemuOptsList runtime_opts = { }, }; -static void nvme_init_queue(BlockDriverState *bs, NVMeQueue *q, +static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, int nentries, int entry_bytes, Error **errp) { - BDRVNVMeState *s = bs->opaque; size_t bytes; int r; @@ -225,14 +224,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, req->prp_list_page = q->prp_list_pages + i * s->page_size; req->prp_list_iova = prp_list_iova + i * s->page_size; } - nvme_init_queue(bs, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); + nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; } q->sq.doorbell = &s->regs->doorbells[idx * 2 * s->doorbell_scale]; - nvme_init_queue(bs, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); + nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; From patchwork Thu Jun 25 18:48:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279410 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6E6AC433E0 for ; Thu, 25 Jun 2020 19:02:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7FB4220679 for ; Thu, 25 Jun 2020 19:02:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CtDJeMgV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FB4220679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX8v-0003xi-Px for qemu-devel@archiver.kernel.org; Thu, 25 Jun 2020 15:02:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWwj-00011y-MX for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:50:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59827 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joWwh-0001I9-LM for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:50:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J6KNnPouNo074HwjJp3LZ774db1owVLbnaAdPIC0ay4=; b=CtDJeMgVSW8Sej7hPhaxqCW20Aq1cCJ2DJDovjBBbQCi4/uAIVrcLoCXZpyeauemoPDjgL qExCCHRgj3q1ce1ntld6o0Wfwtr5+NnTYE5MLds+w9aZNltNkz5geHflWUvI6B3EgbABst MGic8Crc0e3QfIIJdj9C2WRsGrFjAk4= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-482-bTJjE_jrOf-9zmri1r_1XQ-1; Thu, 25 Jun 2020 14:49:52 -0400 X-MC-Unique: bTJjE_jrOf-9zmri1r_1XQ-1 Received: by mail-wr1-f69.google.com with SMTP id y16so7685440wrr.20 for ; Thu, 25 Jun 2020 11:49:52 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=J6KNnPouNo074HwjJp3LZ774db1owVLbnaAdPIC0ay4=; b=IvdQ66F3xfERsLjXW22J1z7cnyOgSMqlznXStnoA6DW8oLFE36bjw+inXm7IdtLX3p fUUq5P8axeQB1jyA/RE9TcFMMB4rgMir09R01424Tnp/aylXSd5r4dVcJkSZ1M75Pj+P BQJ7dN/Jv3kabJwntxvdGny5/ZmD2EJO2RByC9zGxIm4/+FE3oCskY8ltem87iKXzBeD 8M08liLqBHvvyweBCLEwSqmwOZMNIxyX3xBaWMTYOcPawBtYbZhrC5iFdRMxvaxB6e/u NCQ064vbg0vrp8CmKQFeCGUFC4XEzGDLrZXbnBQTGi6mTTA/taKPpj7llPq5yZlKabHs Jb/A== X-Gm-Message-State: AOAM531i1FFjRhLCVaNgvr6dPLv01BoctP63myYEA/7DfanKDW+m3HBh m+lIKA5jgu++h9EcyupXTIkmMq2eaZECJ67DtEdq1UVHPiOZ6/wb0anJvvCHXjXcarZL9TNP1MZ SOgASsoXn7WDC9Yw= X-Received: by 2002:a05:600c:2045:: with SMTP id p5mr5352532wmg.91.1593110991002; Thu, 25 Jun 2020 11:49:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/2Wk8W3TCFa0pSd5Pg0O29Xw/XHbyw8/JZaS9NHCmqmadJh7UszD8vJp+rwy4knFS8xOAqQ== X-Received: by 2002:a05:600c:2045:: with SMTP id p5mr5352516wmg.91.1593110990770; Thu, 25 Jun 2020 11:49:50 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id c2sm33371926wrv.47.2020.06.25.11.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [RFC PATCH 15/17] block/nvme: Use per-queue AIO context Date: Thu, 25 Jun 2020 20:48:36 +0200 Message-Id: <20200625184838.28172-16-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625184838.28172-1-philmd@redhat.com> References: <20200625184838.28172-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Maxim Levitsky , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" To be able to use multiple queues on the same hardware, we need to have each queue able to receive IRQ notifications in the correct AIO context. The context has to be proper to each queue, not to the block driver. Move aio_context from BDRVNVMeState to NVMeQueuePair. Signed-off-by: Philippe Mathieu-Daudé --- RFC because I'm not familiar with AIO context block/nvme.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index ac933cafd0..0f7cc568ef 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -51,6 +51,7 @@ typedef struct { } NVMeRequest; typedef struct { + AioContext *aio_context; CoQueue free_req_queue; QemuMutex lock; @@ -93,7 +94,6 @@ QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) != 0x1000); #define QUEUE_INDEX_IO(n) (1 + n) typedef struct { - AioContext *aio_context; QEMUVFIOState *vfio; NVMeRegs *regs; /* The submission/completion queue pairs. @@ -190,6 +190,7 @@ static void nvme_free_req_queue_cb(void *opaque) } static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, + AioContext *aio_context, int idx, int size, Error **errp) { @@ -207,6 +208,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, if (!q->prp_list_pages) { goto fail; } + q->aio_context = aio_context; memset(q->prp_list_pages, 0, s->page_size * NVME_QUEUE_SIZE); qemu_mutex_init(&q->lock); q->index = idx; @@ -365,7 +367,7 @@ static bool nvme_process_completion(BDRVNVMeState *s, NVMeQueuePair *q) smp_mb_release(); *q->cq.doorbell = cpu_to_le32(q->cq.head); if (!qemu_co_queue_empty(&q->free_req_queue)) { - replay_bh_schedule_oneshot_event(s->aio_context, + replay_bh_schedule_oneshot_event(q->aio_context, nvme_free_req_queue_cb, q); } } @@ -419,7 +421,6 @@ static void nvme_cmd_sync_cb(void *opaque, int ret) static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, NvmeCmd *cmd) { - AioContext *aio_context = bdrv_get_aio_context(bs); NVMeRequest *req; BDRVNVMeState *s = bs->opaque; int ret = -EINPROGRESS; @@ -429,7 +430,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, } nvme_submit_command(s, q, req, cmd, nvme_cmd_sync_cb, &ret); - AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS); + AIO_WAIT_WHILE(q->aio_context, ret == -EINPROGRESS); return ret; } @@ -547,7 +548,8 @@ static void nvme_handle_event(EventNotifier *n) nvme_poll_queues(s); } -static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) +static bool nvme_add_io_queue(BlockDriverState *bs, + AioContext *aio_context, Error **errp) { BDRVNVMeState *s = bs->opaque; int n = s->nr_queues; @@ -555,7 +557,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) NvmeCmd cmd; int queue_size = NVME_QUEUE_SIZE; - q = nvme_create_queue_pair(s, n, queue_size, errp); + q = nvme_create_queue_pair(s, aio_context, n, queue_size, errp); if (!q) { return false; } @@ -600,6 +602,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, Error **errp) { BDRVNVMeState *s = bs->opaque; + AioContext *aio_context = bdrv_get_aio_context(bs); int ret; uint64_t cap; uint64_t timeout_ms; @@ -610,7 +613,6 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, qemu_co_queue_init(&s->dma_flush_queue); s->device = g_strdup(device); s->nsid = namespace; - s->aio_context = bdrv_get_aio_context(bs); ret = event_notifier_init(&s->irq_notifier, 0); if (ret) { error_setg(errp, "Failed to init event notifier"); @@ -660,7 +662,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, /* Set up admin queue. */ s->queues = g_new(NVMeQueuePair *, 1); - s->queues[QUEUE_INDEX_ADMIN] = nvme_create_queue_pair(s, 0, + s->queues[QUEUE_INDEX_ADMIN] = nvme_create_queue_pair(s, aio_context, 0, NVME_QUEUE_SIZE, errp); if (!s->queues[QUEUE_INDEX_ADMIN]) { @@ -695,7 +697,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, if (ret) { goto out; } - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, + aio_set_event_notifier(aio_context, &s->irq_notifier, false, nvme_handle_event, nvme_poll_cb); nvme_identify(bs, namespace, &local_err); @@ -706,7 +708,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, } /* Set up command queues. */ - if (!nvme_add_io_queue(bs, errp)) { + if (!nvme_add_io_queue(bs, aio_context, errp)) { ret = -EIO; } out: @@ -775,11 +777,11 @@ static void nvme_close(BlockDriverState *bs) BDRVNVMeState *s = bs->opaque; for (i = 0; i < s->nr_queues; ++i) { + aio_set_event_notifier(s->queues[i]->aio_context, + &s->irq_notifier, false, NULL, NULL); nvme_free_queue_pair(s->queues[i]); } g_free(s->queues); - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, - false, NULL, NULL); event_notifier_cleanup(&s->irq_notifier); qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE); qemu_vfio_close(s->vfio); @@ -992,7 +994,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs, .cdw12 = cpu_to_le32(cdw12), }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1101,7 +1103,7 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs) .nsid = cpu_to_le32(s->nsid), }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1142,7 +1144,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1192,7 +1194,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1289,7 +1291,6 @@ static void nvme_attach_aio_context(BlockDriverState *bs, { BDRVNVMeState *s = bs->opaque; - s->aio_context = new_context; aio_set_event_notifier(new_context, &s->irq_notifier, false, nvme_handle_event, nvme_poll_cb); } From patchwork Thu Jun 25 18:48:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38AF0C433DF for ; Thu, 25 Jun 2020 18:59:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 033D9204EA for ; Thu, 25 Jun 2020 18:59:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RkordxYH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 033D9204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX6J-0000Og-9w for qemu-devel@archiver.kernel.org; Thu, 25 Jun 2020 14:59:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWwj-00011P-CL for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:50:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54712 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joWwg-0001Hy-W5 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:50:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W4wec89u4s96YVwMymO+Q5mdvwnxmENfWLL0RnTiJ8Y=; b=RkordxYH0w+0SRM/pxwP4JHP1fJoEvXweA1WjHupvwaswkbmMakxp+Hqy3+UkPnO+r4XXc whO59NMx+Z+dROunUEbklovfWM8rEdz+f1XIS5/XjZn4s4i6WSuPphF0yM/rnDa+nNA3ML nWDE98UCuYEDMs+65A022tF/Q4b1YEQ= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-86-hdrtvRq8PwuNm1bFcQ4V8A-1; Thu, 25 Jun 2020 14:49:56 -0400 X-MC-Unique: hdrtvRq8PwuNm1bFcQ4V8A-1 Received: by mail-wr1-f70.google.com with SMTP id y16so7685830wrr.20 for ; Thu, 25 Jun 2020 11:49:56 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=W4wec89u4s96YVwMymO+Q5mdvwnxmENfWLL0RnTiJ8Y=; b=hCPgfROVMI5WV/dbSoLmQC68uU0qadGdFQj0EVXO5PVJH0wdKTyRxFSycEMykm/TiS sPfKMVDWUot0ZBOOQ1e2KcHzW2Ibpf1Pc9VYWdGlMxeasxTIFQgFFfbN9aEmZU6CyGnL KNcXl4H25CqVzF5py7MTLapESzctQRLtaW3Bxx0Ycn2MLqH682MQ639LmzdB55xtDlq2 wSLCC7SdhKPwaIVHQ0hO/WGA0wK8HqpH0Pe6DMJADDbB+LQt4ZZSqQqXxLrE/1T67yT3 1FtZz5qpTBD0p7N9zVVXmZl0DxvhHWA2rjhanR+TV6o+JtuC2ERU1JVXfe9eQOcYalzE ft2w== X-Gm-Message-State: AOAM5329MTrDxw0ihI3d+2O7Zk/tzEfkZerH2xK5hPmwmKvx2SwodGBg //BrmySRa8xmRup7QvTc/jmq1yBhVXcCUc5eYG8pn4FtlJEXbChbTzrW3QnwXTsgs8kfGDMUDiw eKqWf5RGDOQePZG0= X-Received: by 2002:adf:dd83:: with SMTP id x3mr37799049wrl.292.1593110995503; Thu, 25 Jun 2020 11:49:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ8HuyoF1owJXlan8Mtv2B7sWMA6iZuvUTAzosX7lgFT6esWUQ6gxu10pFu5ntVniIChwEyA== X-Received: by 2002:adf:dd83:: with SMTP id x3mr37799031wrl.292.1593110995352; Thu, 25 Jun 2020 11:49:55 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id z132sm7830713wmb.21.2020.06.25.11.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 16/17] block/nvme: Check BDRVNVMeState::plugged out of nvme_kick() Date: Thu, 25 Jun 2020 20:48:37 +0200 Message-Id: <20200625184838.28172-17-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625184838.28172-1-philmd@redhat.com> References: <20200625184838.28172-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Maxim Levitsky , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The queues are tied to the hardware, not to the block driver. As this function doesn't need to know about the BDRVNVMeState, move the 'plugged' check to the caller. Since in nvme_aio_unplug() we know that s->plugged is false, we don't need the check. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 0f7cc568ef..b335dfdb73 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -246,9 +246,9 @@ fail: } /* With q->lock */ -static void nvme_kick(BDRVNVMeState *s, NVMeQueuePair *q) +static void nvme_kick(NVMeQueuePair *q) { - if (s->plugged || !q->need_kick) { + if (!q->need_kick) { return; } trace_nvme_kick(q->index); @@ -406,7 +406,9 @@ static void nvme_submit_command(BDRVNVMeState *s, NVMeQueuePair *q, q->sq.tail * NVME_SQ_ENTRY_BYTES, cmd, sizeof(*cmd)); q->sq.tail = (q->sq.tail + 1) % NVME_QUEUE_SIZE; q->need_kick++; - nvme_kick(s, q); + if (!s->plugged) { + nvme_kick(q); + } nvme_process_completion(s, q); qemu_mutex_unlock(&q->lock); } @@ -1311,7 +1313,7 @@ static void nvme_aio_unplug(BlockDriverState *bs) for (i = QUEUE_INDEX_IO(0); i < s->nr_queues; i++) { NVMeQueuePair *q = s->queues[i]; qemu_mutex_lock(&q->lock); - nvme_kick(s, q); + nvme_kick(q); nvme_process_completion(s, q); qemu_mutex_unlock(&q->lock); } From patchwork Thu Jun 25 18:48:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279416 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B914C433DF for ; Thu, 25 Jun 2020 18:53:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8CC0206BE for ; Thu, 25 Jun 2020 18:53:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PBnfH4pC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8CC0206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX09-0006OW-2y for qemu-devel@archiver.kernel.org; Thu, 25 Jun 2020 14:53:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWwo-00019t-2W for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:50:06 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:31461 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joWwm-0001KX-9Z for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:50:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593111003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tl+gLEZwGkUrjAxE+tzn7ayeWCnvtfJEgm2So8A1ED8=; b=PBnfH4pCtCmkQp1EEPTFLKf7KtDeMHxmQ1oUBmdlHvRFVOytVzqqGHhIPmISyRs9w5mHFm tXtv7TsGWhw42SvRXFlLVFwgx3q+YIkwQ1nFIk85yp2EBU5L9xVgM2bCaQUlN0cXIAZ+pk zbDxBi9+dlTKV1m5YFzhFUqpewvLGwg= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-DYkX4lxGPk6rJDLB6ffBuQ-1; Thu, 25 Jun 2020 14:50:01 -0400 X-MC-Unique: DYkX4lxGPk6rJDLB6ffBuQ-1 Received: by mail-wr1-f69.google.com with SMTP id g14so7728427wrp.8 for ; Thu, 25 Jun 2020 11:50:01 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=tl+gLEZwGkUrjAxE+tzn7ayeWCnvtfJEgm2So8A1ED8=; b=eG3KoY1Ua5rDBOu5/sNWPsFwTDDNmdChiG8BbTasmwplyW0oGE9A065nPKsgS5WXMx +eK6iF/DdRXokYdYUb5xFfZuObeRtJqygbpAgwQFUBg1+sP5vm7ZcFhNPAORMlbpSqrF ktV4EM0IB4GQvkoS1LsFtXa6FWbrQPQDrN13ckZuYUnFpB7J6wI/XS9/w+GzeXsTGxWk 3VxE0Hkgr0HtwQrD0Cu9MViN8Dl0Y0WgnQfWtND+Txzm2X3y88Eqi7v/1HwCeCsN+Q4j pSRfnMY1p4kvPC83g8qeIi/MxUxwch+McK36phZfnRzWZp5xKLkTvdnUoHF6FTbl02mo jkLg== X-Gm-Message-State: AOAM5334n1/bT9VLV4uIRaovzeAGZC9yB7cuqqL2DL6NbF+w9XFKiNKr TiDDgMFAwnI4Im7IntwXtC7CxuH0v2wB5Db9MGoSD+nOCgZQh7AjXRKOPQardmjfVsTYAeHpHNF 9r75mt4tOLL5EnOk= X-Received: by 2002:a5d:4845:: with SMTP id n5mr21970120wrs.353.1593111000139; Thu, 25 Jun 2020 11:50:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl/+O6qurqDErKCYYuBGgege6IM/0PYqI0v8PHqM7CAKpQAyJqyb57LgVC4vM/g6Ftdca9JQ== X-Received: by 2002:a5d:4845:: with SMTP id n5mr21970104wrs.353.1593110999984; Thu, 25 Jun 2020 11:49:59 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id c65sm13273274wme.8.2020.06.25.11.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 17/17] block/nvme: Check BDRVNVMeState::plugged out of nvme_process_completion Date: Thu, 25 Jun 2020 20:48:38 +0200 Message-Id: <20200625184838.28172-18-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625184838.28172-1-philmd@redhat.com> References: <20200625184838.28172-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 01:47:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Maxim Levitsky , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The queues are tied to the hardware, not to the block driver. As this function doesn't need to know about the BDRVNVMeState, move the 'plugged' check to the caller. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index b335dfdb73..03658776f4 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -318,7 +318,7 @@ static inline int nvme_translate_error(const NvmeCqe *c) } /* With q->lock */ -static bool nvme_process_completion(BDRVNVMeState *s, NVMeQueuePair *q) +static bool nvme_process_completion(NVMeQueuePair *q) { bool progress = false; NVMeRequest *preq; @@ -326,7 +326,7 @@ static bool nvme_process_completion(BDRVNVMeState *s, NVMeQueuePair *q) NvmeCqe *c; trace_nvme_process_completion(q->index, q->inflight); - if (q->busy || s->plugged) { + if (q->busy) { trace_nvme_process_completion_queue_busy(q->index); return false; } @@ -408,8 +408,8 @@ static void nvme_submit_command(BDRVNVMeState *s, NVMeQueuePair *q, q->need_kick++; if (!s->plugged) { nvme_kick(q); + nvme_process_completion(q); } - nvme_process_completion(s, q); qemu_mutex_unlock(&q->lock); } @@ -529,10 +529,13 @@ static bool nvme_poll_queues(BDRVNVMeState *s) bool progress = false; int i; + if (s->plugged) { + return false; + } for (i = 0; i < s->nr_queues; i++) { NVMeQueuePair *q = s->queues[i]; qemu_mutex_lock(&q->lock); - while (nvme_process_completion(s, q)) { + while (nvme_process_completion(q)) { /* Keep polling */ progress = true; } @@ -1314,7 +1317,7 @@ static void nvme_aio_unplug(BlockDriverState *bs) NVMeQueuePair *q = s->queues[i]; qemu_mutex_lock(&q->lock); nvme_kick(q); - nvme_process_completion(s, q); + nvme_process_completion(q); qemu_mutex_unlock(&q->lock); } }