From patchwork Mon May 4 09:46:40 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: 1282369 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=2001:470:142::17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TxnpYM5h; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49FylL3f8Gz9sSk for ; Mon, 4 May 2020 19:50:22 +1000 (AEST) Received: from localhost ([::1]:43950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVXjw-0000t6-6i for incoming@patchwork.ozlabs.org; Mon, 04 May 2020 05:50:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVXgv-0005I0-1V for qemu-devel@nongnu.org; Mon, 04 May 2020 05:47:13 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40619 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 1jVXgu-0004I0-6B for qemu-devel@nongnu.org; Mon, 04 May 2020 05:47:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588585631; 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=/BjE+qPatMIH8JRaVlHLK+nrshlFKwJmEw5HEwgChSI=; b=TxnpYM5h8PkaBF6Q2aNL1bRfwsLRi/gKOakM16p/49ivchG4mKxR8/Je/Fx0o5pzsFQEtp 298nEHaz8piTWZbHoq8Wa4tm/wVSXkCLuL/LTeR8Qq62MLhnX+UQMDzUsaRqULPleYNK4h lOlpisbotH68NCPDHrjlE6oN6ZwEX4E= 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-102-2qJW49hpNzahHZASnQJy5g-1; Mon, 04 May 2020 05:47:08 -0400 X-MC-Unique: 2qJW49hpNzahHZASnQJy5g-1 Received: by mail-wm1-f72.google.com with SMTP id j5so4579299wmi.4 for ; Mon, 04 May 2020 02:47:08 -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=+xH2/obfEES+FKWIXC5ZKjL0sJeWRGwNhoW0/uWIJ1w=; b=gibpyiOJjOn7f+RobOPa0JWqu0R/3KTK6isaWL4M7xSZipaTbWEBhbMJoNeGdQ8vXp aJHf7KvM0xESGmI+MDJl7/LhOneNZrdEkEJkC4/3nh1KPZNqv0vYRc/PgymEd6DLh33F DerNsT+0DklQjVk4z6dolv0KtQLP57p8NnLkWNpeQfyGlFbjRpv5VWnuBO4UKjPmhgGg 3PdIBJLExgybiREyGHMpftXJR2A/90gd9eIB74CkdhDTPMnO4t3UJ+Uu77UYf7THkgpO UU/9IlGxscSYfEmkek7imqetgHgZw0m4Y00BLIluGqeAcQDMQ5RKg2Hi9cxZq3LOOjrz y1zQ== X-Gm-Message-State: AGi0Pua+qWzuO6Q8W7bmEf5moM7EFZeMDBw144//eKZ/bi/WcMUpSHhJ rSZz+fSdWCP4hfFIFR6cl/KRgUCQ18At1FTeSHBVYkaDVZYOYqf+JWi+lBV2MAZKH/5BakXQITO 4L5ACtAw8js6uUhA= X-Received: by 2002:a1c:e187:: with SMTP id y129mr14733609wmg.133.1588585627097; Mon, 04 May 2020 02:47:07 -0700 (PDT) X-Google-Smtp-Source: APiQypKduCzSN8JET1vXC5kL0rPakq69kLfHpWqFMvifkhX1yvkqSymuByrgkGqnBdcDs4YhcdavnQ== X-Received: by 2002:a1c:e187:: with SMTP id y129mr14733587wmg.133.1588585626925; Mon, 04 May 2020 02:47:06 -0700 (PDT) Received: from x1w.redhat.com (26.red-88-21-207.staticip.rima-tde.net. [88.21.207.26]) by smtp.gmail.com with ESMTPSA id r20sm12184725wmh.26.2020.05.04.02.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 02:47:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/6] block/nvme: Align block pages queue to host page size Date: Mon, 4 May 2020 11:46:40 +0200 Message-Id: <20200504094641.4963-6-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200504094641.4963-1-philmd@redhat.com> References: <20200504094641.4963-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/05/04 01:21:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, DKIMWL_WL_HIGH=0.001, 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=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Laurent Vivier , Maxim Levitsky , Keith Busch , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefan Hajnoczi , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In nvme_create_queue_pair() we create a page list using qemu_blockalign(), then map it with qemu_vfio_dma_map(): 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, ...); With: s->page_size = MAX(4096, 1 << (12 + ((cap >> 48) & 0xF))); The qemu_vfio_dma_map() documentation says "The caller need to make sure the area is aligned to page size". While we use multiple s->page_size as alignment, it might be not sufficient on some hosts. Use the qemu_real_host_page_size value to be sure the host alignment is respected. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: David Gibson --- Cc: Cédric Le Goater Cc: David Gibson Cc: Laurent Vivier --- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 7b7c0cc5d6..bde0d28b39 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -627,7 +627,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, s->page_size = MAX(4096, 1 << (12 + ((cap >> 48) & 0xF))); s->doorbell_scale = (4 << (((cap >> 32) & 0xF))) / sizeof(uint32_t); - bs->bl.opt_mem_alignment = s->page_size; + bs->bl.opt_mem_alignment = MAX(qemu_real_host_page_size, s->page_size); timeout_ms = MIN(500 * ((cap >> 24) & 0xFF), 30000); /* Reset device to get a clean state. */