Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1317136/?format=api
{ "id": 1317136, "url": "http://patchwork.ozlabs.org/api/patches/1317136/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20200625184838.28172-4-philmd@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20200625184838.28172-4-philmd@redhat.com>", "list_archive_url": null, "date": "2020-06-25T18:48:24", "name": "[03/17] block/nvme: Define QUEUE_INDEX macros to ease code review", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "79c1a4ee9287087bee57b244655ab83c45a79065", "submitter": { "id": 74995, "url": "http://patchwork.ozlabs.org/api/people/74995/?format=api", "name": "Philippe Mathieu-Daudé", "email": "philmd@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20200625184838.28172-4-philmd@redhat.com/mbox/", "series": [ { "id": 185846, "url": "http://patchwork.ozlabs.org/api/series/185846/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=185846", "date": "2020-06-25T18:48:21", "name": "block/nvme: Various cleanups required to use multiple queues", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/185846/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1317136/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1317136/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=<UNKNOWN>)", "ozlabs.org;\n dmarc=fail (p=none dis=none) header.from=redhat.com", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=VGVr6P6S;\n\tdkim-atps=neutral" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 49t8KZ229Rz9sRf\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 26 Jun 2020 04:53:06 +1000 (AEST)", "from localhost ([::1]:50150 helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1joWzf-0004pU-V9\n\tfor incoming@patchwork.ozlabs.org; Thu, 25 Jun 2020 14:53:03 -0400", "from eggs.gnu.org ([2001:470:142:3::10]:40080)\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <philmd@redhat.com>) id 1joWvm-0007rh-9n\n for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:02 -0400", "from us-smtp-1.mimecast.com ([207.211.31.81]:57957\n helo=us-smtp-delivery-1.mimecast.com)\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256)\n (Exim 4.90_1) (envelope-from <philmd@redhat.com>) id 1joWvk-0000wp-L1\n for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:49:01 -0400", "from mail-wm1-f70.google.com (mail-wm1-f70.google.com\n [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-495-eBZj8wxTOfC0_7MVoR3Mzg-1; Thu, 25 Jun 2020 14:48:56 -0400", "by mail-wm1-f70.google.com with SMTP id a21so7770596wmd.0\n for <qemu-devel@nongnu.org>; Thu, 25 Jun 2020 11:48:56 -0700 (PDT)", "from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net.\n [83.51.162.1])\n by smtp.gmail.com with ESMTPSA id f14sm16513976wro.90.2020.06.25.11.48.53\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 25 Jun 2020 11:48:54 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1593110940;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=3lKu2bLyLD7fPfOalxcX/nhKuHHYEWSy1yNdZN63cz4=;\n b=VGVr6P6SuHMcojTKL7E3ggQ+wPXnkaze5ibaE32uNlFFzlOJDMvQFdrlBQ4Txmf7QQBAbb\n SIbTx6HXYi1A+30X400NHZHjDibVrmeShbK56qxWMOV2bOur29MVLiN/MP7dybQd2LTTJ6\n I6frZHStnL9yG51HFhzNsigvYm2fYEg=", "X-MC-Unique": "eBZj8wxTOfC0_7MVoR3Mzg-1", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20161025;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=3lKu2bLyLD7fPfOalxcX/nhKuHHYEWSy1yNdZN63cz4=;\n b=Cy/JMBaYsUaipyrckOVEg7shzKRrp1MPVmK7ewwVND9UoCZq48Qv8qN2NmDAosZWMo\n dkTe1+8bNzpOsQsjO0vjoWxR9maY+hcch7YeXSdYXk2G252SINAWrDValryETXbJeK9u\n lzmaicAx+5MBQ8IXyN4yJmrvAKcEv6iQJs89yOb3bIB/tHXG+2KHRQj7jzJ5PNVygij/\n xEKo+Y67ZhdQJkqkaBmxVELHQyZ8UltRVinncrorXSjhQUCVd+Hv5oQX2/hBhtnJhqGX\n 2gdeKanQvf4GGAeI0YxxyqZo1mOmXmEiIFYi7eSY2FmjE8IK8p0Ej3o90qqCQuoF4p3r\n 013g==", "X-Gm-Message-State": "AOAM530cbKnlEjMabZ0FifMOJQhnXHDh0FPg4Oxln2rfHvrXzyyldMRe\n d+tBdx/024oTw880NIUVfIUJXpObTgBshT2FdtImHiUlAoLdW3ZyWG2zgvJmxEsnoQM4CmsSnWL\n lTwErRmeJqz/0Aq4=", "X-Received": [ "by 2002:a5d:4649:: with SMTP id j9mr7478237wrs.270.1593110934888;\n Thu, 25 Jun 2020 11:48:54 -0700 (PDT)", "by 2002:a5d:4649:: with SMTP id j9mr7478221wrs.270.1593110934658;\n Thu, 25 Jun 2020 11:48:54 -0700 (PDT)" ], "X-Google-Smtp-Source": "\n ABdhPJx450ca/v+IpqoY6PdDyrswPoGGtcjmNYWJ9pzcdZReqGBpyZBRt1O3d+kPTyF+bubzeG8gOg==", "From": "=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@redhat.com>", "To": "qemu-devel@nongnu.org,\n\tStefan Hajnoczi <stefanha@redhat.com>", "Subject": "[PATCH 03/17] block/nvme: Define QUEUE_INDEX macros to ease code\n 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", "Content-Type": "text/plain; charset=UTF-8;\n\ttext/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com;\n 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,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,\n 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": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,\n qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>,\n Maxim Levitsky <mlevitsk@redhat.com>,\n =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@redhat.com>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "Use definitions instead of '0' or '1' indexes. Also this will\nbe useful when using multi-queues later.\n\nSigned-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>\n---\n block/nvme.c | 33 +++++++++++++++++++--------------\n 1 file changed, 19 insertions(+), 14 deletions(-)", "diff": "diff --git a/block/nvme.c b/block/nvme.c\nindex ec0dd21b6e..71f8cf27a8 100644\n--- a/block/nvme.c\n+++ b/block/nvme.c\n@@ -89,6 +89,9 @@ typedef volatile struct {\n \n QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) != 0x1000);\n \n+#define QUEUE_INDEX_ADMIN 0\n+#define QUEUE_INDEX_IO(n) (1 + n)\n+\n typedef struct {\n AioContext *aio_context;\n QEMUVFIOState *vfio;\n@@ -459,7 +462,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)\n }\n cmd.prp1 = cpu_to_le64(iova);\n \n- if (nvme_cmd_sync(bs, s->queues[0], &cmd)) {\n+ if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) {\n error_setg(errp, \"Failed to identify controller\");\n goto out;\n }\n@@ -483,7 +486,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)\n \n cmd.cdw10 = 0;\n cmd.nsid = cpu_to_le32(namespace);\n- if (nvme_cmd_sync(bs, s->queues[0], &cmd)) {\n+ if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) {\n error_setg(errp, \"Failed to identify namespace\");\n goto out;\n }\n@@ -560,7 +563,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)\n .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)),\n .cdw11 = cpu_to_le32(0x3),\n };\n- if (nvme_cmd_sync(bs, s->queues[0], &cmd)) {\n+ if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) {\n error_setg(errp, \"Failed to create io queue [%d]\", n);\n nvme_free_queue_pair(bs, q);\n return false;\n@@ -571,7 +574,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)\n .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)),\n .cdw11 = cpu_to_le32(0x1 | (n << 16)),\n };\n- if (nvme_cmd_sync(bs, s->queues[0], &cmd)) {\n+ if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) {\n error_setg(errp, \"Failed to create io queue [%d]\", n);\n nvme_free_queue_pair(bs, q);\n return false;\n@@ -655,16 +658,18 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,\n \n /* Set up admin queue. */\n s->queues = g_new(NVMeQueuePair *, 1);\n- s->queues[0] = nvme_create_queue_pair(bs, 0, NVME_QUEUE_SIZE, errp);\n- if (!s->queues[0]) {\n+ s->queues[QUEUE_INDEX_ADMIN] = nvme_create_queue_pair(bs, 0,\n+ NVME_QUEUE_SIZE,\n+ errp);\n+ if (!s->queues[QUEUE_INDEX_ADMIN]) {\n ret = -EINVAL;\n goto out;\n }\n s->nr_queues = 1;\n QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000);\n s->regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << 16) | NVME_QUEUE_SIZE);\n- s->regs->asq = cpu_to_le64(s->queues[0]->sq.iova);\n- s->regs->acq = cpu_to_le64(s->queues[0]->cq.iova);\n+ s->regs->asq = cpu_to_le64(s->queues[QUEUE_INDEX_ADMIN]->sq.iova);\n+ s->regs->acq = cpu_to_le64(s->queues[QUEUE_INDEX_ADMIN]->cq.iova);\n \n /* After setting up all control registers we can enable device now. */\n s->regs->cc = cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << 20) |\n@@ -755,7 +760,7 @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable,\n .cdw11 = cpu_to_le32(enable ? 0x01 : 0x00),\n };\n \n- ret = nvme_cmd_sync(bs, s->queues[0], &cmd);\n+ ret = nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd);\n if (ret) {\n error_setg(errp, \"Failed to configure NVMe write cache\");\n }\n@@ -972,7 +977,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs,\n {\n int r;\n BDRVNVMeState *s = bs->opaque;\n- NVMeQueuePair *ioq = s->queues[1];\n+ NVMeQueuePair *ioq = s->queues[QUEUE_INDEX_IO(0)];\n NVMeRequest *req;\n \n uint32_t cdw12 = (((bytes >> s->blkshift) - 1) & 0xFFFF) |\n@@ -1087,7 +1092,7 @@ static coroutine_fn int nvme_co_pwritev(BlockDriverState *bs,\n static coroutine_fn int nvme_co_flush(BlockDriverState *bs)\n {\n BDRVNVMeState *s = bs->opaque;\n- NVMeQueuePair *ioq = s->queues[1];\n+ NVMeQueuePair *ioq = s->queues[QUEUE_INDEX_IO(0)];\n NVMeRequest *req;\n NvmeCmd cmd = {\n .opcode = NVME_CMD_FLUSH,\n@@ -1118,7 +1123,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs,\n BdrvRequestFlags flags)\n {\n BDRVNVMeState *s = bs->opaque;\n- NVMeQueuePair *ioq = s->queues[1];\n+ NVMeQueuePair *ioq = s->queues[QUEUE_INDEX_IO(0)];\n NVMeRequest *req;\n \n uint32_t cdw12 = ((bytes >> s->blkshift) - 1) & 0xFFFF;\n@@ -1171,7 +1176,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs,\n int bytes)\n {\n BDRVNVMeState *s = bs->opaque;\n- NVMeQueuePair *ioq = s->queues[1];\n+ NVMeQueuePair *ioq = s->queues[QUEUE_INDEX_IO(0)];\n NVMeRequest *req;\n NvmeDsmRange *buf;\n QEMUIOVector local_qiov;\n@@ -1300,7 +1305,7 @@ static void nvme_aio_unplug(BlockDriverState *bs)\n BDRVNVMeState *s = bs->opaque;\n assert(s->plugged);\n s->plugged = false;\n- for (i = 1; i < s->nr_queues; i++) {\n+ for (i = QUEUE_INDEX_IO(0); i < s->nr_queues; i++) {\n NVMeQueuePair *q = s->queues[i];\n qemu_mutex_lock(&q->lock);\n nvme_kick(s, q);\n", "prefixes": [ "03/17" ] }