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: 11625931 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48B481392 for ; Thu, 25 Jun 2020 18:51:51 +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 1F060206BE for ; Thu, 25 Jun 2020 18:51:50 +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 1F060206BE 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+patchwork-qemu-devel=patchwork.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-Ug for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:51:49 -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+patchwork-qemu-devel=patchwork.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: 11625939 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 967C51392 for ; Thu, 25 Jun 2020 18:53:52 +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 6D292206BE for ; Thu, 25 Jun 2020 18:53:52 +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 6D292206BE 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+patchwork-qemu-devel=patchwork.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 1joX0R-0007d6-LY for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:53:51 -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+patchwork-qemu-devel=patchwork.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é Reviewed-by: Stefan Hajnoczi --- 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:24 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: 11625937 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7D361392 for ; Thu, 25 Jun 2020 18:53:22 +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 AEB5C206BE for ; Thu, 25 Jun 2020 18:53:22 +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="VGVr6P6S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AEB5C206BE 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joWzx-0006TF-UJ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:53:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWvm-0007rh-9n for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:02 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:57957 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 1joWvk-0000wp-L1 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110940; 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=3lKu2bLyLD7fPfOalxcX/nhKuHHYEWSy1yNdZN63cz4=; b=VGVr6P6SuHMcojTKL7E3ggQ+wPXnkaze5ibaE32uNlFFzlOJDMvQFdrlBQ4Txmf7QQBAbb SIbTx6HXYi1A+30X400NHZHjDibVrmeShbK56qxWMOV2bOur29MVLiN/MP7dybQd2LTTJ6 I6frZHStnL9yG51HFhzNsigvYm2fYEg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-eBZj8wxTOfC0_7MVoR3Mzg-1; Thu, 25 Jun 2020 14:48:56 -0400 X-MC-Unique: eBZj8wxTOfC0_7MVoR3Mzg-1 Received: by mail-wm1-f70.google.com with SMTP id a21so7770596wmd.0 for ; Thu, 25 Jun 2020 11:48: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=3lKu2bLyLD7fPfOalxcX/nhKuHHYEWSy1yNdZN63cz4=; b=Cy/JMBaYsUaipyrckOVEg7shzKRrp1MPVmK7ewwVND9UoCZq48Qv8qN2NmDAosZWMo dkTe1+8bNzpOsQsjO0vjoWxR9maY+hcch7YeXSdYXk2G252SINAWrDValryETXbJeK9u lzmaicAx+5MBQ8IXyN4yJmrvAKcEv6iQJs89yOb3bIB/tHXG+2KHRQj7jzJ5PNVygij/ xEKo+Y67ZhdQJkqkaBmxVELHQyZ8UltRVinncrorXSjhQUCVd+Hv5oQX2/hBhtnJhqGX 2gdeKanQvf4GGAeI0YxxyqZo1mOmXmEiIFYi7eSY2FmjE8IK8p0Ej3o90qqCQuoF4p3r 013g== X-Gm-Message-State: AOAM530cbKnlEjMabZ0FifMOJQhnXHDh0FPg4Oxln2rfHvrXzyyldMRe d+tBdx/024oTw880NIUVfIUJXpObTgBshT2FdtImHiUlAoLdW3ZyWG2zgvJmxEsnoQM4CmsSnWL lTwErRmeJqz/0Aq4= X-Received: by 2002:a5d:4649:: with SMTP id j9mr7478237wrs.270.1593110934888; Thu, 25 Jun 2020 11:48:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx450ca/v+IpqoY6PdDyrswPoGGtcjmNYWJ9pzcdZReqGBpyZBRt1O3d+kPTyF+bubzeG8gOg== X-Received: by 2002:a5d:4649:: with SMTP id j9mr7478221wrs.270.1593110934658; Thu, 25 Jun 2020 11:48:54 -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 f14sm16513976wro.90.2020.06.25.11.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:48:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 03/17] block/nvme: Define QUEUE_INDEX macros to ease code review Date: Thu, 25 Jun 2020 20:48:24 +0200 Message-Id: <20200625184838.28172-4-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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Use definitions instead of '0' or '1' indexes. Also this will be useful when using multi-queues later. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index ec0dd21b6e..71f8cf27a8 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -89,6 +89,9 @@ typedef volatile struct { QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) != 0x1000); +#define QUEUE_INDEX_ADMIN 0 +#define QUEUE_INDEX_IO(n) (1 + n) + typedef struct { AioContext *aio_context; QEMUVFIOState *vfio; @@ -459,7 +462,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) } cmd.prp1 = cpu_to_le64(iova); - if (nvme_cmd_sync(bs, s->queues[0], &cmd)) { + if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to identify controller"); goto out; } @@ -483,7 +486,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) cmd.cdw10 = 0; cmd.nsid = cpu_to_le32(namespace); - if (nvme_cmd_sync(bs, s->queues[0], &cmd)) { + if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to identify namespace"); goto out; } @@ -560,7 +563,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), .cdw11 = cpu_to_le32(0x3), }; - if (nvme_cmd_sync(bs, s->queues[0], &cmd)) { + 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); return false; @@ -571,7 +574,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), .cdw11 = cpu_to_le32(0x1 | (n << 16)), }; - if (nvme_cmd_sync(bs, s->queues[0], &cmd)) { + 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); return false; @@ -655,16 +658,18 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, /* Set up admin queue. */ s->queues = g_new(NVMeQueuePair *, 1); - s->queues[0] = nvme_create_queue_pair(bs, 0, NVME_QUEUE_SIZE, errp); - if (!s->queues[0]) { + s->queues[QUEUE_INDEX_ADMIN] = nvme_create_queue_pair(bs, 0, + NVME_QUEUE_SIZE, + errp); + if (!s->queues[QUEUE_INDEX_ADMIN]) { ret = -EINVAL; goto out; } s->nr_queues = 1; QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000); s->regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << 16) | NVME_QUEUE_SIZE); - s->regs->asq = cpu_to_le64(s->queues[0]->sq.iova); - s->regs->acq = cpu_to_le64(s->queues[0]->cq.iova); + s->regs->asq = cpu_to_le64(s->queues[QUEUE_INDEX_ADMIN]->sq.iova); + s->regs->acq = cpu_to_le64(s->queues[QUEUE_INDEX_ADMIN]->cq.iova); /* After setting up all control registers we can enable device now. */ s->regs->cc = cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << 20) | @@ -755,7 +760,7 @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable, .cdw11 = cpu_to_le32(enable ? 0x01 : 0x00), }; - ret = nvme_cmd_sync(bs, s->queues[0], &cmd); + ret = nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd); if (ret) { error_setg(errp, "Failed to configure NVMe write cache"); } @@ -972,7 +977,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs, { int r; BDRVNVMeState *s = bs->opaque; - NVMeQueuePair *ioq = s->queues[1]; + NVMeQueuePair *ioq = s->queues[QUEUE_INDEX_IO(0)]; NVMeRequest *req; uint32_t cdw12 = (((bytes >> s->blkshift) - 1) & 0xFFFF) | @@ -1087,7 +1092,7 @@ static coroutine_fn int nvme_co_pwritev(BlockDriverState *bs, static coroutine_fn int nvme_co_flush(BlockDriverState *bs) { BDRVNVMeState *s = bs->opaque; - NVMeQueuePair *ioq = s->queues[1]; + NVMeQueuePair *ioq = s->queues[QUEUE_INDEX_IO(0)]; NVMeRequest *req; NvmeCmd cmd = { .opcode = NVME_CMD_FLUSH, @@ -1118,7 +1123,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, BdrvRequestFlags flags) { BDRVNVMeState *s = bs->opaque; - NVMeQueuePair *ioq = s->queues[1]; + NVMeQueuePair *ioq = s->queues[QUEUE_INDEX_IO(0)]; NVMeRequest *req; uint32_t cdw12 = ((bytes >> s->blkshift) - 1) & 0xFFFF; @@ -1171,7 +1176,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, int bytes) { BDRVNVMeState *s = bs->opaque; - NVMeQueuePair *ioq = s->queues[1]; + NVMeQueuePair *ioq = s->queues[QUEUE_INDEX_IO(0)]; NVMeRequest *req; NvmeDsmRange *buf; QEMUIOVector local_qiov; @@ -1300,7 +1305,7 @@ static void nvme_aio_unplug(BlockDriverState *bs) BDRVNVMeState *s = bs->opaque; assert(s->plugged); s->plugged = false; - for (i = 1; i < s->nr_queues; i++) { + 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); 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: 11625917 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 054371392 for ; Thu, 25 Jun 2020 18:50:18 +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 CF839206BE for ; Thu, 25 Jun 2020 18:50:17 +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 CF839206BE 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+patchwork-qemu-devel=patchwork.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 1joWwy-0001RT-To for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:50:16 -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+patchwork-qemu-devel=patchwork.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:26 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: 11625933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C82892A for ; Thu, 25 Jun 2020 18:52:22 +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 52ED1206BE for ; Thu, 25 Jun 2020 18:52:22 +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="baxh4CP2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52ED1206BE 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:50404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joWyz-0004vZ-Hk for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:52:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWvt-00081f-TF for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:09 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:45118 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 1joWvr-0000xh-KI for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110946; 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=D25/qK3jouvb6CaMBWXVBrYPJJAal8XQQt3oaNzllJ4=; b=baxh4CP2HMXHBtjjhAilTauf3Bx4Id22YBhM+IMh5C8M7x8+4xXmsqvkE4zRdgP1i/pmA4 fnruajdm3SLzr9Sc4ES22TDs9Z3DlwvkKbOmx5HDNCEWszRyFvH5EQe6b49C9WqpnR4/mx V392xxbwpHq6Knd/lop6wNyztF+8WKQ= 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-506-54AGoQVyO_mYYq6HDTjO8g-1; Thu, 25 Jun 2020 14:49:05 -0400 X-MC-Unique: 54AGoQVyO_mYYq6HDTjO8g-1 Received: by mail-wm1-f72.google.com with SMTP id v6so5725498wmg.1 for ; Thu, 25 Jun 2020 11:49:05 -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=D25/qK3jouvb6CaMBWXVBrYPJJAal8XQQt3oaNzllJ4=; b=VSmun/5CU2BsARU7KW0EN/+mK5ubqSR2ltGbZZO5OliOAGwmQz09J7gtt+UDXBWA2b hYBpGQDg4In6/D6cqmad8f4ucnwzb8oiSdvN3SXShf1NG5pVOX85sX2aVUKEhBf+YHu1 DqvWF1Vix9+evDP7KAmMRJ4FKQEgityfLqd5uRi2GDkMGnThxJGU7HpLfyg+gRFabNVb 6RMwpCe0V2C7OYVumfYjtYRZbWKnPMDmMpjU+Mf0OvDIIVBjQjAJTKsR8ixM5AIlxtpO HnetuNdX2Tg7KHxUdEZ/Jb5/CwUDD8kADVXpVlZh7e2Qj6vv/w+EDteN4pr2/xXsvru2 kClw== X-Gm-Message-State: AOAM531S4qLS6xezYb1rh2hVmsyOohlNkWa7xgHVE1l2tMCxd3utoT1r Xcu9Oobc/Wbs4LgjPBcWjOWeyoClbi9TRtxn63I3kTopPwjuTJ8vNBpsygTreWzyaFTKttaf7uB 1UV+5k5zAJIA6xyI= X-Received: by 2002:adf:ed02:: with SMTP id a2mr21006371wro.110.1593110944037; Thu, 25 Jun 2020 11:49:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWhDJ6tss58s/bIUrcVvTbA3/T8YxyahSOQxXh9LEF89jgu5T9YuMy4CKKr/sUQwSeV1DHkA== X-Received: by 2002:adf:ed02:: with SMTP id a2mr21006362wro.110.1593110943859; Thu, 25 Jun 2020 11:49:03 -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 k185sm10423085wmk.47.2020.06.25.11.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 05/17] block/nvme: Replace qemu_try_blockalign0 by qemu_try_blockalign/memset Date: Thu, 25 Jun 2020 20:48:26 +0200 Message-Id: <20200625184838.28172-6-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.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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" In the next commit we'll get ride of qemu_try_blockalign(). To ease review, first replace qemu_try_blockalign0() by explicit calls to qemu_try_blockalign() and memset(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index ffda804a8e..bdddcd975d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -158,12 +158,12 @@ static void nvme_init_queue(BlockDriverState *bs, NVMeQueue *q, bytes = ROUND_UP(nentries * entry_bytes, s->page_size); q->head = q->tail = 0; - q->queue = qemu_try_blockalign0(bs, bytes); - + q->queue = qemu_try_blockalign(bs, bytes); if (!q->queue) { error_setg(errp, "Cannot allocate queue"); return; } + memset(q->queue, 0, bytes); r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); if (r) { error_setg(errp, "Cannot map queue"); @@ -204,11 +204,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, if (!q) { return NULL; } - q->prp_list_pages = qemu_try_blockalign0(bs, + q->prp_list_pages = qemu_try_blockalign(bs, s->page_size * NVME_QUEUE_SIZE); if (!q->prp_list_pages) { goto fail; } + memset(q->prp_list_pages, 0, s->page_size * NVME_QUEUE_SIZE); qemu_mutex_init(&q->lock); q->index = idx; qemu_co_queue_init(&q->free_req_queue); @@ -450,7 +451,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) }; idsz_max = MAX_CONST(sizeof(NvmeIdCtrl), sizeof(NvmeIdNs)); - resp = qemu_try_blockalign0(bs, idsz_max); + resp = qemu_try_blockalign(bs, idsz_max); if (!resp) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; @@ -462,6 +463,8 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) error_setg(errp, "Cannot map buffer for DMA"); goto out; } + + memset(resp, 0, sizeof(NvmeIdCtrl)); cmd.prp1 = cpu_to_le64(iova); if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { @@ -484,7 +487,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) s->supports_write_zeroes = !!(oncs & NVME_ONCS_WRITE_ZEROS); s->supports_discard = !!(oncs & NVME_ONCS_DSM); - memset(resp, 0, 4096); + memset(resp, 0, sizeof(NvmeIdNs)); cmd.cdw10 = 0; cmd.nsid = cpu_to_le32(namespace); @@ -1202,11 +1205,11 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, assert(s->nr_queues > 1); - buf = qemu_try_blockalign0(bs, s->page_size); + buf = qemu_try_blockalign(bs, s->page_size); if (!buf) { return -ENOMEM; } - + memset(buf, 0, s->page_size); buf->nlb = cpu_to_le32(bytes >> s->blkshift); buf->slba = cpu_to_le64(offset >> s->blkshift); buf->cattr = 0; From patchwork Thu Jun 25 18:48:27 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: 11625945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CBE992A for ; Thu, 25 Jun 2020 18:55:51 +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 332B4204EA for ; Thu, 25 Jun 2020 18:55:51 +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="HYrjrHri" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 332B4204EA 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:38068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX2M-00036O-Bn for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:55:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWvy-00089O-8T for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59954 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 1joWvw-000105-JN for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110951; 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=kMFGIAe9F8Mx1E0ELN020rjYS3A4x5nkx01FgAd9ah8=; b=HYrjrHriCDSkcOn0MkTloLhUncUOCtsHX9HjKPKWaIB49FvqC/T+8/a4olEkHIldoGlHCR pM03oj2mv7O+/TIE/BW85mPzL5+olIyHHZaa5CAuirq2xcY8KQa8mYgEzODQQwWZwcdFKV oXDRjl4ZAjCGrGmpz0wXc9nraiFncwA= 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-106-Ysx1IbTnMWaYsYQvie3BYg-1; Thu, 25 Jun 2020 14:49:10 -0400 X-MC-Unique: Ysx1IbTnMWaYsYQvie3BYg-1 Received: by mail-wr1-f69.google.com with SMTP id y16so7681434wrr.20 for ; Thu, 25 Jun 2020 11:49:09 -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=kMFGIAe9F8Mx1E0ELN020rjYS3A4x5nkx01FgAd9ah8=; b=ZZ8hPa6tc+Z0Jo/zj6sgvx4sFutY3Cj9Hw4Ze5Uj3ywXk67xNtd4HHxu2vNYtUNhwg ri7Zf48Kuf5wVecx6wERYexF6zuJ2XhvKKfdJSzZJVAQNUiYG0XdHFdVHHFkL3wItbiU ITFYDqlWWI3LZPsv+d11XuyBOgUljQx3h9aC3LDV54iKDhwjOcUVoiDBXH+aLU8qMmnX YT0qyxsK1io/7lfm17rN77fm+Ys8vEB5CORMSekgA5OUsSn4D8eS3Qc2h3WfZCUb06q/ 9ZxBsf3pcNlCz7Eu7TlstnnsAxXc/gDkFl7vfDcwsPSHtWercS1bNR8Hn2RA6f+ncw4T GWow== X-Gm-Message-State: AOAM532P5GJpV+cfUHPVG+fSnkqGxQ2+fnDnv0P+8yEti1vmAm3gGA2v al6jQhFC/ewk5a2MpDWpxEplGjS9eST7LE4OjRxUH3kOnEn45OB9I+8reRodDrHVojiflFXrBLF A/auy16y9Tz1kESA= X-Received: by 2002:adf:e701:: with SMTP id c1mr35470512wrm.350.1593110948671; Thu, 25 Jun 2020 11:49:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZqCcd9hr13Iv6RBV39StHBd2PX84SsmW5r/RttbrT+dc/MtrAZzt386IwyUPEY0pXfHXCUg== X-Received: by 2002:adf:e701:: with SMTP id c1mr35470500wrm.350.1593110948516; Thu, 25 Jun 2020 11:49:08 -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 a128sm3836778wmd.16.2020.06.25.11.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 06/17] block/nvme: Replace qemu_try_blockalign(bs) by qemu_try_memalign(pg_sz) Date: Thu, 25 Jun 2020 20:48:27 +0200 Message-Id: <20200625184838.28172-7-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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" qemu_try_blockalign() is a generic API that call back to the block driver to return its page alignment. As we call from within the very same driver, we already know to page alignment stored in our state. Remove indirections and use the value from BDRVNVMeState. 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 bdddcd975d..cec9ace3dd 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -158,7 +158,7 @@ static void nvme_init_queue(BlockDriverState *bs, NVMeQueue *q, bytes = ROUND_UP(nentries * entry_bytes, s->page_size); q->head = q->tail = 0; - q->queue = qemu_try_blockalign(bs, bytes); + q->queue = qemu_try_memalign(s->page_size, bytes); if (!q->queue) { error_setg(errp, "Cannot allocate queue"); return; @@ -204,7 +204,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, if (!q) { return NULL; } - q->prp_list_pages = qemu_try_blockalign(bs, + q->prp_list_pages = qemu_try_memalign(s->page_size, s->page_size * NVME_QUEUE_SIZE); if (!q->prp_list_pages) { goto fail; @@ -451,7 +451,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) }; idsz_max = MAX_CONST(sizeof(NvmeIdCtrl), sizeof(NvmeIdNs)); - resp = qemu_try_blockalign(bs, idsz_max); + resp = qemu_try_memalign(s->page_size, idsz_max); if (!resp) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; @@ -1061,7 +1061,7 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes, return nvme_co_prw_aligned(bs, offset, bytes, qiov, is_write, flags); } trace_nvme_prw_buffered(s, offset, bytes, qiov->niov, is_write); - buf = qemu_try_blockalign(bs, bytes); + buf = qemu_try_memalign(s->page_size, bytes); if (!buf) { return -ENOMEM; @@ -1205,7 +1205,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, assert(s->nr_queues > 1); - buf = qemu_try_blockalign(bs, s->page_size); + buf = qemu_try_memalign(s->page_size, s->page_size); if (!buf) { return -ENOMEM; } From patchwork Thu Jun 25 18:48:28 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: 11625941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1326E92A for ; Thu, 25 Jun 2020 18:54:13 +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 DDEAE206BE for ; Thu, 25 Jun 2020 18:54:12 +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="SmcZLZKr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDEAE206BE 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX0m-0008Kj-6m for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:54:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWw2-0008Gm-VH for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:18 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:58806 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 1joWw1-00012I-AF for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110956; 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=m0bzcP/UpAbQ5jPMODfTO9c6ylEsOtXCw+c/HFqzYb0=; b=SmcZLZKrQpaV6bdo4DlLNdTYyu1q+/iMzATK4H54UQ2e1eGa0bbiDKPFtmHpushmPI+/tw 0Im2q8ht5eKCyWNiK7FkpWBRKAaSgoliJIo17RoBUDS49rW8TsRFRj/gkM8JpFn+4JDiRx 23x/ncjV61niO/xwR3R6oIHvA6cFnDo= 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-198-4vIC9PyLP4C1G58ykPQlcQ-1; Thu, 25 Jun 2020 14:49:14 -0400 X-MC-Unique: 4vIC9PyLP4C1G58ykPQlcQ-1 Received: by mail-wr1-f71.google.com with SMTP id a18so7731056wrm.14 for ; Thu, 25 Jun 2020 11:49:14 -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=m0bzcP/UpAbQ5jPMODfTO9c6ylEsOtXCw+c/HFqzYb0=; b=bfj5dfrzAJwL2t65NGayF1nUt39qFivXye/GVLaT45ed5sPJgR3DTQP7TlWujcv0oX nUi7TJhb9CXQ/GAWZsXxf6g1ZJ1+wUW5V7C1HsYzn0O9bCqjgnkyPWhLUY2Xbz+WA8b+ 1us3c9+aKFBTyZynRsdaIIt0xnFywKMjWteGEuo6Tm2HnWRGuXcG2JG93CeObdYEJXVo w8l+maTyw8pv+/Sxo6CM1z8QqUhicsZoEMBiQmR8zaNMWtzU4Cl5LxND7cyLuPVcJqi3 s4URbwcHcinYKvYssd1BY40t2r9+VAm0GLM50JTaydmRFmLOl+TD2VfkozjtQB232JHh 9ekQ== X-Gm-Message-State: AOAM530b2HREUWq7+olG2hNCvrHQkZ5wI02WG41SyY01yD3TX9T+7BV0 5LvdLm5SkjWjNbh3E5aijMneT7g3sL6OQZK6yLiqv7JfL9nmVYWv5o4nP5OauglepoWTrav+x8x 0q+AbUwAjPQdY4fY= X-Received: by 2002:a1c:7c15:: with SMTP id x21mr4623892wmc.146.1593110953484; Thu, 25 Jun 2020 11:49:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ+v+Rr3Z3igwd657UXI2rM8WYawdUWGIyGhgmTRIQrvaFBNzmKuRWfzAtiZOfqee2AyWw8g== X-Received: by 2002:a1c:7c15:: with SMTP id x21mr4623880wmc.146.1593110953328; Thu, 25 Jun 2020 11:49:13 -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 v66sm14152417wme.13.2020.06.25.11.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 07/17] block/nvme: Move code around Date: Thu, 25 Jun 2020 20:48:28 +0200 Message-Id: <20200625184838.28172-8-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.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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Move assignments previous to where the assigned variable is used, to make the nvme_identify() body easier to review. No logical change. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index cec9ace3dd..1bba496294 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -456,17 +456,15 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) 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, idsz_max, true, &iova); if (r) { error_setg(errp, "Cannot map buffer for DMA"); goto out; } - memset(resp, 0, sizeof(NvmeIdCtrl)); + idctrl = (NvmeIdCtrl *)resp; + memset(idctrl, 0, sizeof(NvmeIdCtrl)); cmd.prp1 = cpu_to_le64(iova); - if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to identify controller"); goto out; @@ -487,8 +485,8 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) s->supports_write_zeroes = !!(oncs & NVME_ONCS_WRITE_ZEROS); s->supports_discard = !!(oncs & NVME_ONCS_DSM); - memset(resp, 0, sizeof(NvmeIdNs)); - + idns = (NvmeIdNs *)resp; + memset(idns, 0, sizeof(NvmeIdNs)); cmd.cdw10 = 0; cmd.nsid = cpu_to_le32(namespace); if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { 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: 11625947 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A5381392 for ; Thu, 25 Jun 2020 18:55:57 +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 DE652204EA for ; Thu, 25 Jun 2020 18:55: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="SoCD7dC+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE652204EA 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+patchwork-qemu-devel=patchwork.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 1joX2S-0003HA-4Y for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:55:56 -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+patchwork-qemu-devel=patchwork.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é Reviewed-by: Stefan Hajnoczi --- 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: 11625943 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D84FE92A for ; Thu, 25 Jun 2020 18:55:13 +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 AE67F2081A for ; Thu, 25 Jun 2020 18:55:13 +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 AE67F2081A 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+patchwork-qemu-devel=patchwork.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 1joX1k-0001pS-T9 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:55:12 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_free_queue_pair() doesn't use BlockDriverState, remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- 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: 11625951 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22EF392A for ; Thu, 25 Jun 2020 18:57:46 +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 EE19F204EA for ; Thu, 25 Jun 2020 18:57:45 +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 EE19F204EA 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+patchwork-qemu-devel=patchwork.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 1joX4D-0005st-7R for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:57:45 -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+patchwork-qemu-devel=patchwork.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é Reviewed-by: Stefan Hajnoczi --- 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:32 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: 11625929 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 286901392 for ; Thu, 25 Jun 2020 18:50: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 F1384206BE for ; Thu, 25 Jun 2020 18:50:55 +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="glvhgNhw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1384206BE 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joWxb-0002Ui-4B for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:50:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWwL-0000Q0-63 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58121 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 1joWwJ-0001Ct-Jw for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110975; 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=yhVxBJvHaMprPq0QsBU2YvfiwAoYvUlawZjaw5wxXvI=; b=glvhgNhwDQXWcrEAceNLoM3YJVJr4y3Ny4gMe1dWoXkuaSKKVrNNtcBinIM1qMeYSve7yr ro3W1JukLTMS0UvqnpSE2fNWjzQhJbsRvvzoK02+XDoIeGwKwV4Uhd2QbH47YDGQzdFpMs CyIzIW8lzcTs4Rg/7qZfAw7hYUyHIEM= 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-380-IzRar4haO22VLlb3lMbqag-1; Thu, 25 Jun 2020 14:49:33 -0400 X-MC-Unique: IzRar4haO22VLlb3lMbqag-1 Received: by mail-wr1-f71.google.com with SMTP id a18so7732794wrm.14 for ; Thu, 25 Jun 2020 11:49:33 -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=yhVxBJvHaMprPq0QsBU2YvfiwAoYvUlawZjaw5wxXvI=; b=K4EpiHFaFoZGg4NS8zfr4CtKrsR+uWUvUA/DOgYVuS2fMiJi8zFqgAF7+Huvr2wDLf dp64Wh5ZXYBjyKQdENs5sPZP3kQyd/03VcuRazV2BBdyU5xEamaUuYEVbCA8sTIMT/vV 5kKiXCNDKqzDmGIPgpa5KzNQIPKPwYtXqNX3gjfFI4x2yNVSr3fxg0cM2kRKZK7UuZgx MpUjboZ8Pyvow9xo4TKRZTFMxcOulCwcjh1eNKdpK5syOlTqzTI4o1iwg/wTBp2Mw+pT +1n0TlKkYCsEf1nLdv8T8mJK2/NHl3cPmUPUbHHwIlOqqLWb36TjkMQ+buGKaIQPIXXr j4yg== X-Gm-Message-State: AOAM53369PlD5A6Mef4REg4ah4UR9WKbBN9jUOOWHm3g64ssixQcKWJv 1PEReOGDrGJdzgDAzWmeXValGXhwzYHK7VZiyTtMFZl9xQtkDU4kIWr7wQuYwQ9sAi9af8tRvCM nOEDPs0vlhcnw7mY= X-Received: by 2002:a7b:cbcb:: with SMTP id n11mr4686002wmi.99.1593110972125; Thu, 25 Jun 2020 11:49:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6POyqdvauFTVFDCZsPZR2UnEhQWtss0Y5W6sr2ytfyzTAilIIy129pKwSq8oLsKQGZ1jkLg== X-Received: by 2002:a7b:cbcb:: with SMTP id n11mr4685989wmi.99.1593110971962; Thu, 25 Jun 2020 11:49:31 -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 p25sm13334331wmg.39.2020.06.25.11.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 11/17] block/nvme: Simplify nvme_create_queue_pair() arguments Date: Thu, 25 Jun 2020 20:48:32 +0200 Message-Id: <20200625184838.28172-12-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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_create_queue_pair() doesn't require BlockDriverState anymore. Replace it by BDRVNVMeState to simplify. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 8b6cf4c34b..1b7b23cea4 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -189,12 +189,11 @@ static void nvme_free_req_queue_cb(void *opaque) qemu_mutex_unlock(&q->lock); } -static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, +static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, int idx, int size, Error **errp) { int i, r; - BDRVNVMeState *s = bs->opaque; Error *local_err = NULL; NVMeQueuePair *q; uint64_t prp_list_iova; @@ -555,7 +554,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) NvmeCmd cmd; int queue_size = NVME_QUEUE_SIZE; - q = nvme_create_queue_pair(bs, n, queue_size, errp); + q = nvme_create_queue_pair(s, n, queue_size, errp); if (!q) { return false; } @@ -660,7 +659,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(bs, 0, + s->queues[QUEUE_INDEX_ADMIN] = nvme_create_queue_pair(s, 0, NVME_QUEUE_SIZE, errp); if (!s->queues[QUEUE_INDEX_ADMIN]) { From patchwork Thu Jun 25 18:48:33 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: 11625949 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A12692A for ; Thu, 25 Jun 2020 18:57:44 +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 3F7F3204EA for ; Thu, 25 Jun 2020 18:57:44 +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="DC8GO5un" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F7F3204EA 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX4B-0005pM-H1 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:57:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWwR-0000Uq-Ah for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:43 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:38810 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 1joWwO-0001DS-Q2 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110979; 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=vdHB3c1POu+gM3bxvvPOf+lWl4pEeZKZAvtWWJ0/JLg=; b=DC8GO5unD7fDJcGcO+1jjYs4PohfyXrq6P7TeDkZn+UuSa0v3hIDqI3rNhBIUvaTo2uMIi nOt/DSEmJ+AS5bIinHPu7stt9keLFHcSYNIBSKQ4quFHBI7jQuO6KKCKpUv29lAqUTMnpI CUlWous9AHs+xEEl3NoEPw81jaWjDaM= 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-209-LiD0eN7JM8WerV7NYl2z-A-1; Thu, 25 Jun 2020 14:49:38 -0400 X-MC-Unique: LiD0eN7JM8WerV7NYl2z-A-1 Received: by mail-wm1-f71.google.com with SMTP id b13so5759117wme.9 for ; Thu, 25 Jun 2020 11:49:38 -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=vdHB3c1POu+gM3bxvvPOf+lWl4pEeZKZAvtWWJ0/JLg=; b=eeCHjjGuU1tOtit+Ytb3joQIJFGSCrc2jZT/a4rKXBP9OVPJsUCPOURBp3aoMQVR2u I8Y0rFP6AlN6FGjoBKQ19s4XdzUt6LwK2+TBHH4xaaPRwU7/hHNHzeCYUpBxH0vH42nU GqtdumGLNF3009kyTyk2aibKjjEUuXPkCUc2fjFIdZUF80chRcMDQNda5mkwQUeB9EQK QoWy4TTzGyO5WIpelQC8lO/9W0hHVGS1eu2TT4FdZNOf8DOTEXoapaBK2dcTEbe1GaXF MCbMtYY49JcsLNYhjaGUOVmySR5wKeaYo/Qvyi9xFC2dxHiDUqn1rMvRHNxKgsiphpsC 5RFw== X-Gm-Message-State: AOAM533O06yBVvWAB/fCsJ7Z8C7g2edraC/tirF8F19baIQpjc6wKcUI 1Da2WYRiEI5sL/uaB61PAzD8241dLh+l2pBuLUzHbrieL/NY2zprtIB2RiGrVG+eWEXo7B4XNSx lUjqbILeA//lai7I= X-Received: by 2002:a1c:4343:: with SMTP id q64mr4972481wma.20.1593110976809; Thu, 25 Jun 2020 11:49:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPNjPcX1y3BgRbnefEuZFWO96dtThFLq0XOx8wNtq258fIXU7m/llkftNUnvww60hczLCQdQ== X-Received: by 2002:a1c:4343:: with SMTP id q64mr4972473wma.20.1593110976638; Thu, 25 Jun 2020 11:49:36 -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 11sm13769708wmg.41.2020.06.25.11.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 12/17] block/nvme: Simplify nvme_kick trace event Date: Thu, 25 Jun 2020 20:48:33 +0200 Message-Id: <20200625184838.28172-13-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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The queues are tied to the hardware, logging the block driver using them is irrelevant. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 2 +- block/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 1b7b23cea4..4d2f31a9b3 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -249,7 +249,7 @@ static void nvme_kick(BDRVNVMeState *s, NVMeQueuePair *q) if (s->plugged || !q->need_kick) { return; } - trace_nvme_kick(s, q->index); + trace_nvme_kick(q->index); assert(!(q->sq.tail & 0xFF00)); /* Fence the write to submission queue entry before notifying the device. */ smp_wmb(); diff --git a/block/trace-events b/block/trace-events index 29dff8881c..f0c476110b 100644 --- a/block/trace-events +++ b/block/trace-events @@ -154,7 +154,7 @@ vxhs_close(char *vdisk_guid) "Closing vdisk %s" vxhs_get_creds(const char *cacert, const char *client_key, const char *client_cert) "cacert %s, client_key %s, client_cert %s" # nvme.c -nvme_kick(void *s, int queue) "s %p queue %d" +nvme_kick(int queue) "queue %d" nvme_dma_flush_queue_wait(void *s) "s %p" nvme_error(int cmd_specific, int sq_head, int sqid, int cid, int status) "cmd_specific %d sq_head %d sqid %d cid %d status 0x%x" nvme_process_completion(void *s, int index, int inflight) "s %p queue %d inflight %d" From patchwork Thu Jun 25 18:48:34 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: 11625953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 804CA1392 for ; Thu, 25 Jun 2020 18:59:40 +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 46D19204EA for ; Thu, 25 Jun 2020 18:59:40 +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="eKqzdiEH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46D19204EA 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX63-0000Ha-Gh for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:59:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWwV-0000Xx-5l for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58261 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 1joWwT-0001Eb-GG for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110984; 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=nIyn1saCYFaGdm81Oq09Kelp7+BVTinz9yQeBa0Ppdk=; b=eKqzdiEHYDpWr3eIunwBJWZb0yNTIcwCtLx1rrJwB/5w8QlE01b53zlfxWg1FfMNWHpRMb u8stBlaTS3DtRL6KHjuRSaATYRfMMnSN9cnqftv6E3UawXyHEHo8mvgxC1OErjbJjiPA5S wMXDzAr+c/I1yw5utVgj76thyOvrBdw= 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-182-rM6LbJIcMcOQalWV-RDAtA-1; Thu, 25 Jun 2020 14:49:43 -0400 X-MC-Unique: rM6LbJIcMcOQalWV-RDAtA-1 Received: by mail-wm1-f71.google.com with SMTP id b13so5759504wme.9 for ; Thu, 25 Jun 2020 11:49:42 -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=nIyn1saCYFaGdm81Oq09Kelp7+BVTinz9yQeBa0Ppdk=; b=hHUenbVKrDVisnSYffdkjRsimUqdSoxG1pbrN0LeCDGz5Kl/mUBHZBkAkMPQVe5KYC hqfA8beUiwz9PC7onmSevtdBKpD7PGkY03S4WGcSjU5vf2lf5rSgzCcDxWkbqqczUOsN v+fQQScUA8AniqXBY5YMbGnjz85hBU0Ox6kJdq/++FkoBFUCVGexMn1BVzfVzC5eKpFQ 2Bn6Zcq9tLCqq3dXY2GSXpKxkqZEQ68Ig2Vx+5o4LLkelNuvkNan8RHncYP7g8b1ch64 zE2nE1vD2khnVgbE+17OrYFcrolDBz9Hatnzs+4vxRI+BJrY/FjQTo4D+IlPQmkteSbt OyMQ== X-Gm-Message-State: AOAM532Ql3yikNOYn30RP+5O5A2AHTheZzb0M657+xmVMKPgD4TVSQBf EpsdnKBQJLD150K/AQ9tNiZxTsb4+flLFCZRO+G4zsl3cnPyEAMelBw+hig0JI3LsD+ZA6cKz7q sdFffur5Ow1BRsIY= X-Received: by 2002:a7b:cc92:: with SMTP id p18mr5116307wma.4.1593110981539; Thu, 25 Jun 2020 11:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrN5WhKifX3bF6GBGntQNfgDBAxDswnG/6+iyql1L1EUDXPF1e2r0kZ4ACoEUb4ZtxxdaK4A== X-Received: by 2002:a7b:cc92:: with SMTP id p18mr5116294wma.4.1593110981383; Thu, 25 Jun 2020 11:49:41 -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 o9sm32321361wrs.1.2020.06.25.11.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 13/17] block/nvme: Simplify completion trace events Date: Thu, 25 Jun 2020 20:48:34 +0200 Message-Id: <20200625184838.28172-14-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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The queues are tied to the hardware, logging the block driver using them is irrelevant. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 6 +++--- block/trace-events | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 4d2f31a9b3..7b983ba4e1 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -323,9 +323,9 @@ static bool nvme_process_completion(BDRVNVMeState *s, NVMeQueuePair *q) NVMeRequest req; NvmeCqe *c; - trace_nvme_process_completion(s, q->index, q->inflight); + trace_nvme_process_completion(q->index, q->inflight); if (q->busy || s->plugged) { - trace_nvme_process_completion_queue_busy(s, q->index); + trace_nvme_process_completion_queue_busy(q->index); return false; } q->busy = true; @@ -347,7 +347,7 @@ static bool nvme_process_completion(BDRVNVMeState *s, NVMeQueuePair *q) continue; } assert(cid <= NVME_QUEUE_SIZE); - trace_nvme_complete_command(s, q->index, cid); + trace_nvme_complete_command(q->index, cid); preq = &q->reqs[cid - 1]; req = *preq; assert(req.cid == cid); diff --git a/block/trace-events b/block/trace-events index f0c476110b..8c29818093 100644 --- a/block/trace-events +++ b/block/trace-events @@ -157,9 +157,9 @@ vxhs_get_creds(const char *cacert, const char *client_key, const char *client_ce nvme_kick(int queue) "queue %d" nvme_dma_flush_queue_wait(void *s) "s %p" nvme_error(int cmd_specific, int sq_head, int sqid, int cid, int status) "cmd_specific %d sq_head %d sqid %d cid %d status 0x%x" -nvme_process_completion(void *s, int index, int inflight) "s %p queue %d inflight %d" -nvme_process_completion_queue_busy(void *s, int index) "s %p queue %d" -nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d" +nvme_process_completion(int index, int inflight) "queue %d inflight %d" +nvme_process_completion_queue_busy(int index) "queue %d" +nvme_complete_command(int index, int cid) "queue %d cid %d" nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d" nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, int c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x" nvme_handle_event(void *s) "s %p" From patchwork Thu Jun 25 18:48:35 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: 11625957 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0ABD3618 for ; Thu, 25 Jun 2020 19:02:01 +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 D585520679 for ; Thu, 25 Jun 2020 19:02:00 +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="PSpiWMWH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D585520679 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joX8K-0003oy-5h for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 15:02:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joWwZ-0000h2-K5 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:51 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:30042 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 1joWwX-0001Fq-P6 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593110989; 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=dXASt3Ms0kW/IxtpIXCdPXxIbHHRXq5VPxKgsbFlF6A=; b=PSpiWMWHV7ClDOV04kBw4UscJO3T97i2rawGqSvYUTQImQd4vD4otv0jiN5AO4eDSENodN pS8Qoa0sUO8xWG5T+iO2FuKhb66E8dLWreNI/DDTxdhQDxqJx+Uzyej3yTNYIO9G4u9w/J W3XmDLby3abJqz/GSbGhp3pNIxWn/Fs= 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-227-5NzhVgSjNymtmWd1jaL42A-1; Thu, 25 Jun 2020 14:49:47 -0400 X-MC-Unique: 5NzhVgSjNymtmWd1jaL42A-1 Received: by mail-wm1-f72.google.com with SMTP id v24so8009683wmh.3 for ; Thu, 25 Jun 2020 11:49:47 -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=dXASt3Ms0kW/IxtpIXCdPXxIbHHRXq5VPxKgsbFlF6A=; b=K/87fyDOuou7Y18nxjFvH2TY++eNW/XPYhGYug+GKRfVms+hZ+p9QYZjRrEPCDYEmr gMrIUrmbQideSlO95X9i5lbx/QDYQqS6ZFigyWW1g9UnalHeteriCdfI8L6Tiv9AFctr 3s+77rQjplonPZL2mvcJZy+7v8QQmoAFkPVguuAm5qMXRYeiys7d0KQWcVFZ07BYWmDo NdSPPsvZvljdTPNasEowUcnAn+13z4GrRyXiStxJ44YfY9LNxZz+foobK/SKeNcK1aws hem8MJfpjP0MFNbNYL6kg2v4fDeHhtiuawrXHgABxY1EJeop9YxJyAUj1wFbxmkjHVm4 svog== X-Gm-Message-State: AOAM5306mWd1lJduZR/kvl3FIFBbOWtQjeUMoAoQ1rNbs0Ep3nUyc2v3 Dd81Ic3pyAsdybsp48aLNk7at/5n+LXP/pR+OxgAB3+XoFqBhKmFfGCj4x8o6e22hYQx4vZURN/ 1h/w2cPXOt8rdQes= X-Received: by 2002:a5d:6202:: with SMTP id y2mr1866716wru.32.1593110986313; Thu, 25 Jun 2020 11:49:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxvRxzrrsGeWera0Bg/9MbggcnNfga2FrxDtfOrnxGYJam1O2ZeI0pf1cIadS4CFloAwRnkw== X-Received: by 2002:a5d:6202:: with SMTP id y2mr1866702wru.32.1593110986181; Thu, 25 Jun 2020 11:49:46 -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 3sm7989952wmi.45.2020.06.25.11.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 11:49:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH 14/17] block/nvme: Replace BDRV_POLL_WHILE by AIO_WAIT_WHILE Date: Thu, 25 Jun 2020 20:48:35 +0200 Message-Id: <20200625184838.28172-15-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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" BDRV_POLL_WHILE() is defined as: #define BDRV_POLL_WHILE(bs, cond) ({ \ BlockDriverState *bs_ = (bs); \ AIO_WAIT_WHILE(bdrv_get_aio_context(bs_), \ cond); }) As we will remove the BlockDriverState use in the next commit, start by using the exploded version of BDRV_POLL_WHILE(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 7b983ba4e1..ac933cafd0 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -419,6 +419,7 @@ 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; @@ -428,7 +429,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, } nvme_submit_command(s, q, req, cmd, nvme_cmd_sync_cb, &ret); - BDRV_POLL_WHILE(bs, ret == -EINPROGRESS); + AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS); return ret; } 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: 11625959 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2662A1392 for ; Thu, 25 Jun 2020 19:02:23 +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 F016F20679 for ; Thu, 25 Jun 2020 19:02:22 +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 F016F20679 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+patchwork-qemu-devel=patchwork.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 1joX8g-0003xi-7s for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 15:02:22 -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+patchwork-qemu-devel=patchwork.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: 11625955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8CCB92A for ; Thu, 25 Jun 2020 18:59:43 +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 8F9BF20738 for ; Thu, 25 Jun 2020 18:59:43 +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 8F9BF20738 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+patchwork-qemu-devel=patchwork.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 1joX66-0000Og-R6 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:59:42 -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+patchwork-qemu-devel=patchwork.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é Reviewed-by: Stefan Hajnoczi --- 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: 11625935 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3DAB1392 for ; Thu, 25 Jun 2020 18:53:21 +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 AA4F9206BE for ; Thu, 25 Jun 2020 18:53:21 +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 AA4F9206BE 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+patchwork-qemu-devel=patchwork.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 1joWzw-0006OW-Ul for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Jun 2020 14:53:20 -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+patchwork-qemu-devel=patchwork.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é Reviewed-by: Stefan Hajnoczi --- 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); } }