From patchwork Fri Aug 21 19:53:46 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: 275836 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99CECC433E1 for ; Fri, 21 Aug 2020 19:55: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 5ACF5204EA for ; Fri, 21 Aug 2020 19:55: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="MZe7UayP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5ACF5204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9D8Y-00085Z-IC for qemu-devel@archiver.kernel.org; Fri, 21 Aug 2020 15:55:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9D7C-0006PL-UJ for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46684) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k9D7B-0002fK-8B for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598039656; 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=969biaX/G7f1D/6G5QoxlHmmKW8KQsbMUTT5iH7LPeo=; b=MZe7UayP0qNjMGiEb7tb5/oppge9VcgM/UO5zPI0zaL8w5AZ1zMo8/hhIrsDHXkBegyL68 SLAjj/eEIriMQ607usr1vfyVtYBmJY2/vHZ0BXizRcgjg8mpsaV5fWhg24xtPuQBUFjfV0 9343mAlUsCzRuJxIGy5ktE9clYr+oWE= 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-474-0MFAZjN0NMSZqWvBztomWA-1; Fri, 21 Aug 2020 15:54:14 -0400 X-MC-Unique: 0MFAZjN0NMSZqWvBztomWA-1 Received: by mail-wm1-f72.google.com with SMTP id k204so1374775wmb.3 for ; Fri, 21 Aug 2020 12:54: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=969biaX/G7f1D/6G5QoxlHmmKW8KQsbMUTT5iH7LPeo=; b=UK0AFU0vjSg5gtBaZ+V6cK6ZywkdPCzhs5pDoOxVQ/qpYGednWOokaS0g+d7gMZK9r rg+7ZzrEfSgmoTTfwx/FyXps5h9PnJgZGmzH5nrEo44itfM+J8fBBUmq7F8uPeeuFFQG fgW1w411b80vrbm3Gnmj9QoQqOwF364/OmIIDlVvpBlu4Imd9vxLMevkOMtF9dMm9Gkk bO0yAH1EHIwowoOiUFQgSwQftoBumd0sjsCrpuez7Gl5DjhW6QPEeE3nu1sHDwdXzqPl Ne6+5YffeEaeN9kTPiIOGgYYOclspf47UuuD8l6gVTgdSkfrvN3Tc1m8pm5aZ3nl6t+o 0O2Q== X-Gm-Message-State: AOAM532Nij0ZDr6zkZFzAk+qldOpoadhhwfSgcsHk0WuyfGGlN8anKOf BK/C9qW3xmV5BocVDUs2vc0zVyDjK1wRjUMEPpO/khGVVWNFx5eVLhJjpY9yykuyIsqJm7paHlm WsvA0RNe3KlDvpKM= X-Received: by 2002:a5d:60c2:: with SMTP id x2mr2400675wrt.73.1598039653155; Fri, 21 Aug 2020 12:54:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZMtp1rDhksvpZhU0EoNPybYyltpwgKpxYxPw5/0AcKlG4wRhNKIQcnM0oRFyzHHd/p2Ck1w== X-Received: by 2002:a5d:60c2:: with SMTP id x2mr2400660wrt.73.1598039653005; Fri, 21 Aug 2020 12:54:13 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id x2sm6767121wrg.73.2020.08.21.12.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:54:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 02/15] block/nvme: Avoid further processing if trace event not enabled Date: Fri, 21 Aug 2020 21:53:46 +0200 Message-Id: <20200821195359.1285345-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200821195359.1285345-1-philmd@redhat.com> References: <20200821195359.1285345-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.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/21 02:43:55 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Avoid further processing if TRACE_NVME_SUBMIT_COMMAND_RAW is not enabled. This is an untested intend of performance optimization. Reviewed-by: Stefan Hajnoczi 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 2f5e3c2adfa..8c30a5fee28 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -441,6 +441,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 Fri Aug 21 19:53:50 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: 275834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0187BC433E1 for ; Fri, 21 Aug 2020 19:57: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 BD8452072D for ; Fri, 21 Aug 2020 19:57: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="EBWXQ/Z6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD8452072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9DA9-0003rQ-Va for qemu-devel@archiver.kernel.org; Fri, 21 Aug 2020 15:57:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9D7W-0007FH-Vm for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k9D7V-0002hy-5v for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598039676; 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=7xDCDapdWyub1oQeIVHPwnt1jYU5IQrsPDwy4E3ew7k=; b=EBWXQ/Z6HAdSokCSMSSY+0WxV2HYjYldpFS0IsiMZjgHhUeFWD4hBrEArOL4wPR64BWnPS mVERTwoJr9BLoS/rl0GZUdt2SHQsbMWf5oH7iLOKUYMvmJ8Of9uxWxAILz7TEUneuQqMa3 vMaEuq37IsBtCW6hP6PDUxek0ByAxjk= 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-187-c_oTzyNvNP6-yyMY_NKQ6Q-1; Fri, 21 Aug 2020 15:54:34 -0400 X-MC-Unique: c_oTzyNvNP6-yyMY_NKQ6Q-1 Received: by mail-wm1-f70.google.com with SMTP id k204so1375066wmb.3 for ; Fri, 21 Aug 2020 12:54:34 -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=7xDCDapdWyub1oQeIVHPwnt1jYU5IQrsPDwy4E3ew7k=; b=BQGhbKIMYKqqLwFUuX0cTLeO4C3vHMiHa2JO3H0nNbB9/gt0c3ijsn0RaCeMpexh6e s/XFEWyUWl+MLHya1+2BZYM0z/3p4L8SKSLIB60UKJLq3QsN29XfLRCUgMq7l3y3gx4p ypnVTybmGCVW7wMQIAlzJVnYV2hfCtABnBkWoyouyRJkZjve+d4BJSG+HNjLF0gNvehi 7ukumT0CFkqtc8kHvUjdsG876dasY9YL+onPg5Oum1lfgi+jYMXlG0HROA+OWD9lUVYY cAauNZJsV74LRj5iTqa3Dif6rCO+k8sVzb5jxBmVs3S524KAmKX/ZAubDsN7vsGQ0+k6 nZNQ== X-Gm-Message-State: AOAM531eN5S1UMxat7gbx45WpgwbUXGdSWvVdN0Y7JD53WwN04HcBTFj f8iBg2OZct2aeUJvx4AaGdK32yx6zqu66rsabDJMVXaFTWXK9ZaKTZt1jNdnNO3UzDud/2IU+Uo WvFr5o8VaFZleHe0= X-Received: by 2002:a1c:a54e:: with SMTP id o75mr5468870wme.181.1598039673693; Fri, 21 Aug 2020 12:54:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPe89aAI6gKRcPETnkSxHgC7A8l1QHiyl3gfzMig87o+Kl7saTf6y48FosXkdn25nId9vxSA== X-Received: by 2002:a1c:a54e:: with SMTP id o75mr5468860wme.181.1598039673531; Fri, 21 Aug 2020 12:54:33 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id l17sm6663952wmg.1.2020.08.21.12.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:54:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 06/15] block/nvme: Use common error path in nvme_add_io_queue() Date: Fri, 21 Aug 2020 21:53:50 +0200 Message-Id: <20200821195359.1285345-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200821195359.1285345-1-philmd@redhat.com> References: <20200821195359.1285345-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.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/21 04:26:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Rearrange nvme_add_io_queue() by using a common error path. This will be proven useful in few commits where we add IRQ notification to the IO queues. Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index c63629d3b45..419178adda3 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -649,8 +649,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create CQ io queue [%d]", n); - nvme_free_queue_pair(q); - return false; + goto out_error; } cmd = (NvmeCmd) { .opcode = NVME_ADM_CMD_CREATE_SQ, @@ -660,13 +659,15 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create SQ io queue [%d]", n); - nvme_free_queue_pair(q); - return false; + goto out_error; } s->queues = g_renew(NVMeQueuePair *, s->queues, n + 1); s->queues[n] = q; s->nr_queues++; return true; +out_error: + nvme_free_queue_pair(q); + return false; } static bool nvme_poll_cb(void *opaque) From patchwork Fri Aug 21 19:53:52 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: 275835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81953C433E4 for ; Fri, 21 Aug 2020 19:57:02 +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 4E7D12072D for ; Fri, 21 Aug 2020 19:57:02 +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="V2rinsd0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E7D12072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9D9p-00038f-J8 for qemu-devel@archiver.kernel.org; Fri, 21 Aug 2020 15:57:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9D7k-0007RR-BC for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:53 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:53515 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 1k9D7i-0002kv-PT for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598039690; 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=WtBrq1bijthgDexWbDxZSKtNjp9JLqgaI8U5ThisE0A=; b=V2rinsd0fFKpQf/gmCANZZUJH0DteHMfX9ahKqgQaqriJESSlssu3EbweYSk3jCgyIsA0X b7vOTlmgl7jswx1ij4j9yb1co/YfOs23GEnT3e0uin+truZNlKZXjwWO1ptRFpYLT5a9fw 5MX6lv3nN3JLbk2ZB5+jPZHaiFM5Oek= 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-323-cwKMXIJDNHGa022alVp3EA-1; Fri, 21 Aug 2020 15:54:46 -0400 X-MC-Unique: cwKMXIJDNHGa022alVp3EA-1 Received: by mail-wr1-f70.google.com with SMTP id j2so905744wrr.14 for ; Fri, 21 Aug 2020 12:54: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=WtBrq1bijthgDexWbDxZSKtNjp9JLqgaI8U5ThisE0A=; b=AsTz018KB5DkSMy4ExSpi0+HK2M1Y6JeuB+FuPXD3l6m2oxeCk0lhGB9yZYk18NkOL AmeDlv8A5Oeaq86JPLUoKkfDQN7IEn4SaIVEaXwwhOXnxmmWH4oX341MfPYQh93damTR C/8dIFC46jmEE5E3n5qiD3XP+sPa6x74CrwKNCgqp7D4FcyM9FUtqlEmR+000aqMMlVY cIGrKZJdMv9TAgmQo1yZ9o2SWsWHznkQERBddtTRC1o8WQk6LtlxzuznzlI2ChQgFr+k i9PyLGZTnypmrexbs/oqnBtel5L3qfAlWl0bLlsYH2jYRCpiQtAEXTxUq5k9NFKH1LVt p4Xg== X-Gm-Message-State: AOAM532KrWQRMmylnZBrxVZ45P2IHRFaeSft0rHN5rwRd+DLcbFekSnQ 9rnpYpFIFLH8eClwBf5+vMSAPofwQF4cNAQiRu5z3JrPN0SGO7YEDjobYhXannqYHJQkUpAQ4su jMQKOGbvS6LvYUao= X-Received: by 2002:a1c:7215:: with SMTP id n21mr4506800wmc.156.1598039684788; Fri, 21 Aug 2020 12:54:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVgFwQsWuAYY8uYC/Qoa8fuz/XnCXc1ATlaWF27Pnj+R1KPsBX+A7evqzWWtY6mFxaw6NzxQ== X-Received: by 2002:a1c:7215:: with SMTP id n21mr4506743wmc.156.1598039683888; Fri, 21 Aug 2020 12:54:43 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id j4sm7191494wmi.48.2020.08.21.12.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:54:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 08/15] block/nvme: Use union of NvmeIdCtrl / NvmeIdNs structures Date: Fri, 21 Aug 2020 21:53:52 +0200 Message-Id: <20200821195359.1285345-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200821195359.1285345-1-philmd@redhat.com> References: <20200821195359.1285345-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.002 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/08/21 05:15:56 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We allocate an unique chunk of memory then use it for two different structures. By using an union, we make it clear the data is overlapping (and we can remove the casts). Suggested-by: Stefan Hajnoczi Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 15c5202c03c..af3176a9669 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -508,9 +508,10 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) { BDRVNVMeState *s = bs->opaque; - NvmeIdCtrl *idctrl; - NvmeIdNs *idns; - uint8_t *id; + union { + NvmeIdCtrl ctrl; + NvmeIdNs ns; + } *id; NvmeLBAF *lbaf; uint16_t oncs; int r; @@ -520,14 +521,12 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) .cdw10 = cpu_to_le32(0x1), }; - id = qemu_try_blockalign0(bs, sizeof(NvmeIdCtrl)); + id = qemu_try_blockalign0(bs, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - idctrl = (NvmeIdCtrl *)id; - idns = (NvmeIdNs *)id; - r = qemu_vfio_dma_map(s->vfio, id, sizeof(NvmeIdCtrl), true, &iova); + r = qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova); if (r) { error_setg(errp, "Cannot map buffer for DMA"); goto out; @@ -539,22 +538,22 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) goto out; } - if (le32_to_cpu(idctrl->nn) < namespace) { + if (le32_to_cpu(id->ctrl.nn) < namespace) { error_setg(errp, "Invalid namespace"); goto out; } - s->write_cache_supported = le32_to_cpu(idctrl->vwc) & 0x1; - s->max_transfer = (idctrl->mdts ? 1 << idctrl->mdts : 0) * s->page_size; + s->write_cache_supported = le32_to_cpu(id->ctrl.vwc) & 0x1; + s->max_transfer = (id->ctrl.mdts ? 1 << id->ctrl.mdts : 0) * s->page_size; /* For now the page list buffer per command is one page, to hold at most * s->page_size / sizeof(uint64_t) entries. */ s->max_transfer = MIN_NON_ZERO(s->max_transfer, s->page_size / sizeof(uint64_t) * s->page_size); - oncs = le16_to_cpu(idctrl->oncs); + oncs = le16_to_cpu(id->ctrl.oncs); s->supports_write_zeroes = !!(oncs & NVME_ONCS_WRITE_ZEROS); s->supports_discard = !!(oncs & NVME_ONCS_DSM); - memset(id, 0, 4096); + memset(id, 0, sizeof(*id)); cmd.cdw10 = 0; cmd.nsid = cpu_to_le32(namespace); if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { @@ -562,11 +561,11 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) goto out; } - s->nsze = le64_to_cpu(idns->nsze); - lbaf = &idns->lbaf[NVME_ID_NS_FLBAS_INDEX(idns->flbas)]; + s->nsze = le64_to_cpu(id->ns.nsze); + lbaf = &id->ns.lbaf[NVME_ID_NS_FLBAS_INDEX(id->ns.flbas)]; - if (NVME_ID_NS_DLFEAT_WRITE_ZEROES(idns->dlfeat) && - NVME_ID_NS_DLFEAT_READ_BEHAVIOR(idns->dlfeat) == + if (NVME_ID_NS_DLFEAT_WRITE_ZEROES(id->ns.dlfeat) && + NVME_ID_NS_DLFEAT_READ_BEHAVIOR(id->ns.dlfeat) == NVME_ID_NS_DLFEAT_READ_BEHAVIOR_ZEROES) { bs->supported_write_flags |= BDRV_REQ_MAY_UNMAP; } From patchwork Fri Aug 21 19:53:53 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: 275832 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC106C433DF for ; Fri, 21 Aug 2020 19:58:53 +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 987E820724 for ; Fri, 21 Aug 2020 19:58:53 +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="WJhn2tNK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 987E820724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9DBc-00072b-Pg for qemu-devel@archiver.kernel.org; Fri, 21 Aug 2020 15:58:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9D7n-0007Ws-1e for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k9D7l-0002lJ-BN for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598039692; 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=0i2p9sl3VAF8Jqkhq9VbsKE+8jvhj1TW75WcnxQRvoc=; b=WJhn2tNKwRpQVlUCkFSsCB3Nk5OVQMC1CUjAUMkRb0/sGrhNBlcIFOg2luQFEiP+slexvz 4S4mLZ98EAq7zMc4aK+qIxJUXBk4Je6q5YQJfFuLOP6Cvlv00q1aNrQSpfECw+5qTUxDxf zpBlaFjH6bgkkc4EUpVZaLuv8Sm3Upk= 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-91-epgvYMJDPluMpOZBFPZGxA-1; Fri, 21 Aug 2020 15:54:50 -0400 X-MC-Unique: epgvYMJDPluMpOZBFPZGxA-1 Received: by mail-wm1-f69.google.com with SMTP id p184so1366419wmp.7 for ; Fri, 21 Aug 2020 12:54:50 -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=0i2p9sl3VAF8Jqkhq9VbsKE+8jvhj1TW75WcnxQRvoc=; b=Ea3I3Ry9TwuT0zLwhkZp9EhI8r4jpW9pd/s+SA3yAD+GMgAiyKVL/fPqTFCa60s6Sb 3JfJ4iwDlWG8MmjOwsnIeq6AhbW1rB2kGLDwK9V7UEfS8kHfWHU24uB22OYVzSCfNmIB O7bc4kyqfLCFza174bB/qN/yBUcRJSHr6zEI8deyDislCBPCBDd0fymHQADjwZhIK06j V41G0tceld8JWLAsKI5+IJMlmbf97yDe3i0ZzuElWVufwPhbz0Nnl3MEYDjL4R9XKRdt j2uiojuSveG+vsr75N7DLaTOE1ImrGRHFeM606NrCA8E0Nkl9dc+aP6j1qvto1AKgwlO A8og== X-Gm-Message-State: AOAM530iZPMXB70ZSH6NQhI9PVBO1Uw89hjxZLQSJQmWWOfNKMwN8Uu/ KXHHj6Nk1a4swbTdCH9PnSILrOOkVoz7Y+K9ghE1gXlIVU8RiY0iazWFdHz3H45z8tygwL6KjlF p9sgGTMMPuMHkiOg= X-Received: by 2002:a5d:400e:: with SMTP id n14mr3997272wrp.75.1598039689112; Fri, 21 Aug 2020 12:54:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqgq21Dk4POF4Ky/yB5OC0piWJtmURQ8gZizVXstYdsIkedV9CuwpKT7yavYmSMlMj4Koy/A== X-Received: by 2002:a5d:400e:: with SMTP id n14mr3997265wrp.75.1598039688949; Fri, 21 Aug 2020 12:54:48 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id q2sm6326632wro.8.2020.08.21.12.54.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:54:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 09/15] block/nvme: Replace qemu_try_blockalign0 by qemu_try_blockalign/memset Date: Fri, 21 Aug 2020 21:53:53 +0200 Message-Id: <20200821195359.1285345-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200821195359.1285345-1-philmd@redhat.com> References: <20200821195359.1285345-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.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/21 04:26:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In the next commit we'll get rid of qemu_try_blockalign(). To ease review, first replace qemu_try_blockalign0() by explicit calls to qemu_try_blockalign() and memset(). Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index af3176a9669..7e21a2d7ece 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -174,12 +174,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"); @@ -223,11 +223,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_NUM_REQS); if (!q->prp_list_pages) { goto fail; } + memset(q->prp_list_pages, 0, s->page_size * NVME_NUM_REQS); qemu_mutex_init(&q->lock); q->s = s; q->index = idx; @@ -521,7 +522,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) .cdw10 = cpu_to_le32(0x1), }; - id = qemu_try_blockalign0(bs, sizeof(*id)); + id = qemu_try_blockalign(bs, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; @@ -531,8 +532,9 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) error_setg(errp, "Cannot map buffer for DMA"); goto out; } - cmd.prp1 = cpu_to_le64(iova); + memset(id, 0, sizeof(*id)); + cmd.prp1 = cpu_to_le64(iova); if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to identify controller"); goto out; @@ -1283,11 +1285,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 Fri Aug 21 19:53:54 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: 275831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1FD3C433DF for ; Fri, 21 Aug 2020 20:00:06 +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 8534B20724 for ; Fri, 21 Aug 2020 20:00:06 +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="TJ64AV0F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8534B20724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9DCn-00018K-O5 for qemu-devel@archiver.kernel.org; Fri, 21 Aug 2020 16:00:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9D7r-0007jZ-Iw for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:59 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:22212 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 1k9D7p-0002m5-UU for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:54:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598039697; 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=y47Rdgq2E7ETUgE+8WKfJU6kiExsJ3jsfjk0oBdiMjg=; b=TJ64AV0FaDSDhIjX/pMdz3rLfOWxGJO9vv7QH7Gj+oR7hTXSSM5jmsvDVAbkL0jMEV+BVk gdDW/H7DGMQ6NK7NVwLBbwqXi7S73xcSE8iSbugnKAoSeRlLjkaAC2co2qcTlkGs9gQP1p czof4O23uf9L+gizQr39ThvyodvMHJM= 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-172-nHx7pFaTP42wJU8jJIPdOQ-1; Fri, 21 Aug 2020 15:54:55 -0400 X-MC-Unique: nHx7pFaTP42wJU8jJIPdOQ-1 Received: by mail-wr1-f70.google.com with SMTP id f7so900439wrs.8 for ; Fri, 21 Aug 2020 12:54:55 -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=y47Rdgq2E7ETUgE+8WKfJU6kiExsJ3jsfjk0oBdiMjg=; b=X8kBhiy/gjJRtK0BXXVUD1+LFqTmqz3G9dUILARY4Gi+lwrokVRSDsCwSsu5ilS2Hi 3eAmZEnk+64U81oGgq7Zoe7OD+2C1kkTREImIOpBQ/MGB94DANFbDfAozvEM90+7XB8V xBpowBxEbJKr1l2+THvBS/zHPsU+OK+p3WWALg8eVUMR0/Q3/umIRhv8WmZGFTLvQEXA pvJInXQMPF0t7//zYJVorlWoF9DDR3//jOFQhbWGy0AfT8iEfjJaFqNjh1wpwg8WpYoj 78F6+IbkD5znaREq41Y5t2y7xPl93mLtTtNs5whjTyCYqtbDv0jkdwr5nFBmwLHXMPHj ARnw== X-Gm-Message-State: AOAM531Gi/x+FqZSBuUARB3zahpkyf0p5e+jPTmZmKBJNuhwWsKZI9iO +WZUyJr5i0fZ/bTkiv0n7vmep9tGcPEFOZ4giRKGhUn8Hsc1Xk8DlXHz06orj3M7W6EXOR9Fnav Cp80WYCfRIFqZruc= X-Received: by 2002:adf:fecc:: with SMTP id q12mr4209767wrs.374.1598039694245; Fri, 21 Aug 2020 12:54:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzioq88rRY1lsto/f0vK6mEJOfEKayI8VG4T5ieTqOXLbkNG36iLjFInRQfyeieUbNVwqsYGA== X-Received: by 2002:adf:fecc:: with SMTP id q12mr4209751wrs.374.1598039694016; Fri, 21 Aug 2020 12:54:54 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id o124sm6607073wmb.2.2020.08.21.12.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:54:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 10/15] block/nvme: Replace qemu_try_blockalign(bs) by qemu_try_memalign(pg_sz) Date: Fri, 21 Aug 2020 21:53:54 +0200 Message-Id: <20200821195359.1285345-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200821195359.1285345-1-philmd@redhat.com> References: <20200821195359.1285345-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.003 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/08/21 01:00:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+qemu-devel=archiver.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. This change is required to later remove the BlockDriverState argument, to make nvme_init_queue() per hardware, and not per block driver. Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella 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 7e21a2d7ece..3742e0535aa 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -174,7 +174,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; @@ -223,7 +223,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_NUM_REQS); if (!q->prp_list_pages) { goto fail; @@ -522,7 +522,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) .cdw10 = cpu_to_le32(0x1), }; - id = qemu_try_blockalign(bs, sizeof(*id)); + id = qemu_try_memalign(s->page_size, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; @@ -1141,7 +1141,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; @@ -1285,7 +1285,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 Fri Aug 21 19:53:55 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: 275830 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80849C433DF for ; Fri, 21 Aug 2020 20:01:48 +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 467F52072D for ; Fri, 21 Aug 2020 20:01:48 +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="XeiuPO1S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 467F52072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9DER-0002zu-Gx for qemu-devel@archiver.kernel.org; Fri, 21 Aug 2020 16:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9D7x-0007zW-UZ for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:55:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32038) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k9D7v-0002mP-0f for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:55:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598039702; 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=NuSKQWVrMs8vraRihCSu39r/qzyDiytcvGfDb3sY9wM=; b=XeiuPO1SL6neUUNNyzRjHTzor04Xeij2Tx6XEW72CT6h+DsVSBtR+ZZF+xY5tCAsG+oyv8 8VmaSCSRRDY1DXJ8fJ37zpFVWRlNLJQkSYD/1dA8iB74i54M2d95MTf64HZgkjfSe0iQAI LyTNAGykhpZHzCk+VaBsB58S/TYZyJQ= 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-381-_bOBlJhcNEOaFUTa3gqKrQ-1; Fri, 21 Aug 2020 15:55:01 -0400 X-MC-Unique: _bOBlJhcNEOaFUTa3gqKrQ-1 Received: by mail-wm1-f71.google.com with SMTP id q23so967027wmj.0 for ; Fri, 21 Aug 2020 12:55: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=NuSKQWVrMs8vraRihCSu39r/qzyDiytcvGfDb3sY9wM=; b=gROBEX350gF5osRbDppfsJ4w3xPvAcJcyvUCC2xjkoMTmC6y5nLAv2p8SHH1Bivs0l uHB0/TMpgfTquZYkFxbt3J3kd076v3Wz1jw5Q2uM03QcoxAac5oKScEFGBygZyu8XEz8 1zS1MhUtMPzU5Wm+k8JNF6OJqbOEO9eINQaLP8Sa/KYiHNWbqsuRLyP9AFOSwOxJUJIe 5YLU6MR1KbI198frhGST9oSvyfu7RAXHFY1ziylSCbmHIzy/qO4AojW/DVIleSLybcxO iCkCiWYWKpjaka1/iAhf17lzeXJsO9WG38/oVKC4U4XvGE/4A9pjU0qxLkIWClC4aeKI u6SQ== X-Gm-Message-State: AOAM533nEVuk0VPmxobBZrgA/SFPDGvZiamXAoKw3Ze3m3M/ai5C+Pgf 2DQT3ojAoXOrBRSpEgpfEu4R02QTxrh4vI+rZam9ywoip3Yp8Vc+86fK29b+VeUAXpmTFye9F6E 6cw3iJwwq0VY5tDI= X-Received: by 2002:a7b:cc0b:: with SMTP id f11mr5583590wmh.31.1598039699485; Fri, 21 Aug 2020 12:54:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6ulkCCJMaE+uybsKbrr7aGFvRoA2uMVEhGiA76MIX/fwbV0O9u2wfNic3WNs75VeOjcSQTQ== X-Received: by 2002:a7b:cc0b:: with SMTP id f11mr5583570wmh.31.1598039699286; Fri, 21 Aug 2020 12:54:59 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id x11sm6353387wrl.28.2020.08.21.12.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:54:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 11/15] block/nvme: Simplify nvme_init_queue() arguments Date: Fri, 21 Aug 2020 21:53:55 +0200 Message-Id: <20200821195359.1285345-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200821195359.1285345-1-philmd@redhat.com> References: <20200821195359.1285345-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.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/21 04:26:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_init_queue() doesn't require BlockDriverState anymore. Replace it by BDRVNVMeState to simplify. Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 3742e0535aa..f98ca067144 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -165,10 +165,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; @@ -251,14 +250,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, 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 Fri Aug 21 19:53:56 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: 275833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C69EC433DF for ; Fri, 21 Aug 2020 19:58: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 BD03820724 for ; Fri, 21 Aug 2020 19:58:39 +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="HFXNIgwN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD03820724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9DBO-0006UR-VJ for qemu-devel@archiver.kernel.org; Fri, 21 Aug 2020 15:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9D85-00085j-94 for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:55:13 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:23340 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 1k9D82-0002nN-Qd for qemu-devel@nongnu.org; Fri, 21 Aug 2020 15:55:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598039710; 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=4QkeIEuTWWrDAk5fgLztw4p0UNTKf91orUMJW2LVbIY=; b=HFXNIgwNdhxxot8bqmav4vf0xzOJlkGpDrLbCN70GHEELVOU4suDOJQAcmnxIJ79l2NO0j i7inN8G4GdsHnhcofSWSm5qMubeBWXwLTKK/DdkCEH/BB2K8Fkde9tUtwohC3yMz/ctvFX 0tGXwCW1PWXvglKQ2smYgMkkjuSekzU= 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-347-bXcHSh7tMnOjHvcpF9y6xg-1; Fri, 21 Aug 2020 15:55:06 -0400 X-MC-Unique: bXcHSh7tMnOjHvcpF9y6xg-1 Received: by mail-wm1-f71.google.com with SMTP id k204so1375559wmb.3 for ; Fri, 21 Aug 2020 12:55:06 -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=4QkeIEuTWWrDAk5fgLztw4p0UNTKf91orUMJW2LVbIY=; b=DUSUO9hX2kIY7Vq3mgnIhk5EBKU5B08j72dlejLrTPEyDzfiNjYCXQjHgQkzYe9aby au0EhY2XUFEKSmLRFnuRpJkntrHMjTnqY3zmvamBJrIlpNuAiCI/AY7c0ue3w3DVFviz Ju6/RR5kjmvGUQNYhfbjz5jduAX7+IT1kXoUm5QMYPBfDsdxAQx44yeoP8KXXM1EUFAs hDogS+w5JvIT7mOQoMOr8wZQ0ienNDkoYlTCjR3aA+tLzUILnzpdcqVW1tgLCqw/u6PD C1QaARJcogffV0zldy49Xdx45miiU09yFLH+8wJ9uMXYo63uHoSjQ5OmDsp5Vov9MPiz qNbw== X-Gm-Message-State: AOAM531+jvZm2xPyW1T3bNobJ9A0tq5h5JLCss4NoEUsHPjbIQcfbwNi tl2ydIfJ00QT11d/8UM5GvGE6gLzIOImzjxOpeplk0WgysthVWCsmRcQFuhQ+6pl60hY/CVSJRA d2X/zsOVHqSQ7xz4= X-Received: by 2002:a5d:4241:: with SMTP id s1mr4065586wrr.411.1598039704635; Fri, 21 Aug 2020 12:55:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMpajGP4WqfXOkZJv+j1i7lAsCAEl2/lVIVd6XTuoWAbxhQbxnoz07ynKNkJ1+tBrnBVAeeQ== X-Received: by 2002:a5d:4241:: with SMTP id s1mr4065564wrr.411.1598039704477; Fri, 21 Aug 2020 12:55:04 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id z12sm6514659wrp.20.2020.08.21.12.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:55:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 12/15] block/nvme: Replace BDRV_POLL_WHILE by AIO_WAIT_WHILE Date: Fri, 21 Aug 2020 21:53:56 +0200 Message-Id: <20200821195359.1285345-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200821195359.1285345-1-philmd@redhat.com> References: <20200821195359.1285345-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.002 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/08/21 05:15:56 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+qemu-devel=archiver.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(). Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index f98ca067144..3d49ff81fb7 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -493,6 +493,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; int ret = -EINPROGRESS; req = nvme_get_free_req(q); @@ -501,7 +502,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, } nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret); - BDRV_POLL_WHILE(bs, ret == -EINPROGRESS); + AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS); return ret; }