From nobody Sun Apr 28 00:20:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1679318279; cv=none; d=zohomail.com; s=zohoarc; b=en6MFA7nfVGWE6ejmpAFxZKeX96cs+LNKJ/WDdD/9P5t2dytJgioiNhESup4gTk18WnmWjO2pKzED/Twfgnt7qJz8jalwl6/TQj0xpFL0YDoQCMlA78eFsTpgtK/1koOo+kw1KxgOBYhHTNshG4fY5J8AtQsES+HzI/zmfNAcDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679318279; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=uELllllIT6ap0txurg9j0z4sGzWjdXJWHDI95ZuPdr4=; b=A61yx9HjPGkc7iN3Q0i88oOwZjqtSHKQ33hc8u2fFrklpGjwxMvDFjQataN3k1jt5gyEgRpRlBTuXr+dyaomW05lhQxaiFVoCJUAwxglXVTp61dUM7/oT+bMFsHd//gV6qqrXsTZIBxSPU1mkJdb9xOFAZa8JoZe+s+lPq6s7g4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679318279623570.1877862416762; Mon, 20 Mar 2023 06:17:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1peFOc-0002v3-Uy; Mon, 20 Mar 2023 09:17:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1peEpt-0005tj-En; Mon, 20 Mar 2023 08:42:01 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1peEpr-0007TY-D0; Mon, 20 Mar 2023 08:42:01 -0400 Received: by mail-pl1-x636.google.com with SMTP id o11so12288398ple.1; Mon, 20 Mar 2023 05:41:54 -0700 (PDT) Received: from localhost.localdomain ([134.238.136.60]) by smtp.gmail.com with ESMTPSA id m7-20020aa79007000000b005a8b28c644esm6295016pfo.4.2023.03.20.05.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 05:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679316114; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uELllllIT6ap0txurg9j0z4sGzWjdXJWHDI95ZuPdr4=; b=Exklrgzz0xM9Y0OZRIdvdoIHmDxxVfhIfqatPr6w9FJU+/SrVnT0XoBTPXsLQnzF+O M1CvZR+5QkzcZRFaegxAuSUeU24CPbDPjL+GJnYd7At0FQk5rIzE2Wj02ldMEtJKPF4b /PfwbOaywPY2Qf15GNZJHjpjECAOp7SCS0fg3cKEiwaqAxLMCntPkT4VTJdlz533qBvV gVQIRoG/crWcJdZerUB5r3FqcUDrIrtwEHpyeD/ysiqY+DZ2/in4133GrVuQzFI7I6pD kTpLxZcvEyo/hHqYFqL7RkocBYwQivW5grZ3oGBqvMPz69LZLOO4j0+X2fC8A6Ch5+qX jZ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679316114; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uELllllIT6ap0txurg9j0z4sGzWjdXJWHDI95ZuPdr4=; b=oG43SAO3H1AKkih0Pl51E1Y1f7u/DEA4sudrhhIqfptVY5Gie7y3eODzWYSeSzwaIr auc8GGtCTR43CjjqVfJP9/kgeKVTJpYTW1e2ia1b0bNcXjhJNgsidTMWfIB/9TzUYFAn S8T1/K7Oh0Oc3t950weoOUAGYqF/EYU1GWjEP4D2gkVYbvGDbtvGUUsRuw7glTnAmRjL LFKeKpAbZuudUXEMidTQuP0xuXNKiGtIgmgLWsgG/GDcZx6jM7NIlmHxkScC//vCvjmd fC7yC9O5SPXoAdFF9Gh0IsV/7GBFX2hxnXtxcYJI1kmQWdfIrfhkcAkDtGX7t2FQYUKS SX6g== X-Gm-Message-State: AO0yUKU01sKW2Kv0PWnTHwk6FguN2r525kBsqduz6DD7n/lEvkWfzkMj D4NKqBdrN62wm9ZpWLhS0Ng6K1rQqJBFwkP+nHtLrw== X-Google-Smtp-Source: AK7set/qz+MDASqGMnCgzd9TwzKjTZc9C9vB/yN0ng/5wXSqWhk5vlN2yTFhAu6QvkFF7nvfY42XPw== X-Received: by 2002:a05:6a20:a794:b0:d9:e6a9:d3e2 with SMTP id bx20-20020a056a20a79400b000d9e6a9d3e2mr1775147pzb.3.1679316113777; Mon, 20 Mar 2023 05:41:53 -0700 (PDT) From: Mateusz Kozlowski To: qemu-devel@nongnu.org Cc: mateusz.kozlowski@solidigm.com, Mateusz Kozlowski , Keith Busch , Klaus Jensen , qemu-block@nongnu.org (open list:nvme) Subject: [PATCH] hw/nvme: Change alignment in dma functions for nvme_blk_* Date: Mon, 20 Mar 2023 13:40:36 +0100 Message-Id: <20230320124042.1404-1-kozlowski.mateuszpl@gmail.com> X-Mailer: git-send-email 2.37.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=kozlowski.mateuszpl@gmail.com; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 20 Mar 2023 09:17:43 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1679318281052100001 Content-Type: text/plain; charset="utf-8" Since the nvme_blk_read/write are used by both the data and metadata portions of the IO, it can't have the 512B alignment requirement. Without this change any metadata transfer, which length isn't a multiple of 512B and which is bigger than 512B, will result in only a partial transfer. Signed-off-by: Mateusz Kozlowski Reviewed-by: Klaus Jensen --- hw/nvme/ctrl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 49c1210fce..291009545f 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1434,26 +1434,26 @@ uint16_t nvme_bounce_mdata(NvmeCtrl *n, void *ptr, = uint32_t len, } =20 static inline void nvme_blk_read(BlockBackend *blk, int64_t offset, - BlockCompletionFunc *cb, NvmeRequest *req) + uint32_t align, BlockCompletionFunc *cb, + NvmeRequest *req) { assert(req->sg.flags & NVME_SG_ALLOC); =20 if (req->sg.flags & NVME_SG_DMA) { - req->aiocb =3D dma_blk_read(blk, &req->sg.qsg, offset, BDRV_SECTOR= _SIZE, - cb, req); + req->aiocb =3D dma_blk_read(blk, &req->sg.qsg, offset, align, cb, = req); } else { req->aiocb =3D blk_aio_preadv(blk, offset, &req->sg.iov, 0, cb, re= q); } } =20 static inline void nvme_blk_write(BlockBackend *blk, int64_t offset, - BlockCompletionFunc *cb, NvmeRequest *re= q) + uint32_t align, BlockCompletionFunc *cb, + NvmeRequest *req) { assert(req->sg.flags & NVME_SG_ALLOC); =20 if (req->sg.flags & NVME_SG_DMA) { - req->aiocb =3D dma_blk_write(blk, &req->sg.qsg, offset, BDRV_SECTO= R_SIZE, - cb, req); + req->aiocb =3D dma_blk_write(blk, &req->sg.qsg, offset, align, cb,= req); } else { req->aiocb =3D blk_aio_pwritev(blk, offset, &req->sg.iov, 0, cb, r= eq); } @@ -2207,10 +2207,10 @@ static void nvme_rw_cb(void *opaque, int ret) } =20 if (req->cmd.opcode =3D=3D NVME_CMD_READ) { - return nvme_blk_read(blk, offset, nvme_rw_complete_cb, req= ); + return nvme_blk_read(blk, offset, 1, nvme_rw_complete_cb, = req); } =20 - return nvme_blk_write(blk, offset, nvme_rw_complete_cb, req); + return nvme_blk_write(blk, offset, 1, nvme_rw_complete_cb, req= ); } } =20 @@ -3437,7 +3437,7 @@ static uint16_t nvme_read(NvmeCtrl *n, NvmeRequest *r= eq) =20 block_acct_start(blk_get_stats(blk), &req->acct, data_size, BLOCK_ACCT_READ); - nvme_blk_read(blk, data_offset, nvme_rw_cb, req); + nvme_blk_read(blk, data_offset, BDRV_SECTOR_SIZE, nvme_rw_cb, req); return NVME_NO_COMPLETE; =20 invalid: @@ -3607,7 +3607,7 @@ static uint16_t nvme_do_write(NvmeCtrl *n, NvmeReques= t *req, bool append, =20 block_acct_start(blk_get_stats(blk), &req->acct, data_size, BLOCK_ACCT_WRITE); - nvme_blk_write(blk, data_offset, nvme_rw_cb, req); + nvme_blk_write(blk, data_offset, BDRV_SECTOR_SIZE, nvme_rw_cb, req= ); } else { req->aiocb =3D blk_aio_pwrite_zeroes(blk, data_offset, data_size, BDRV_REQ_MAY_UNMAP, nvme_rw_cb, --=20 2.34.1