From nobody Tue Nov 4 18:44:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530341169435188.09312897413508; Fri, 29 Jun 2018 23:46:09 -0700 (PDT) Received: from localhost ([::1]:45848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ9e4-00019U-Gl for importer@patchew.org; Sat, 30 Jun 2018 02:46:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ96S-0004Y3-Di for qemu-devel@nongnu.org; Sat, 30 Jun 2018 02:11:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZ96R-0002rQ-7f for qemu-devel@nongnu.org; Sat, 30 Jun 2018 02:11:24 -0400 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:40584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZ96R-0002oW-1b for qemu-devel@nongnu.org; Sat, 30 Jun 2018 02:11:23 -0400 Received: by mail-wm0-x22b.google.com with SMTP id z13-v6so3945058wma.5 for ; Fri, 29 Jun 2018 23:11:23 -0700 (PDT) Received: from donizetti.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 24-v6sm563454wrz.94.2018.06.29.23.11.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Jun 2018 23:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GpbcMH2fufJdaO/ozLnLITF9UkoZXjwVMc5nXMxw5Mg=; b=LmNdOV1wEY02r5NYZcFmSiDemREVE+YXwnSvk0shGUHXcop9g5J3hX+fS+73buPa6K oJlYQaHnOJWIHuf39vpn6O37enuRomU39n+kCeTjhsrrx4YnVEHB5GUsStH3Er96tnoK J3dJKXb/5s6AaYaj1aNmy9jYJF80078W5CBciBmeKStGb05+m73ZHWnnIId+9aBZ+lWn qZoC6q/WOTBvwJfKcWzJpQvz8EjQyn+WA5P0tJLvIc+ZSA8r64h8KW3wUY35xX9Sy4Tc oLBADYz3rSQ0B7WGGrJgHjLzxFCYDj4etXaS3vGW3dV6AGDVfnUeeHqbUwWVcJgs0qoD R7xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=GpbcMH2fufJdaO/ozLnLITF9UkoZXjwVMc5nXMxw5Mg=; b=RQGk+sUozZ/6oo2Lt82HuP7bWI9DFocJSkE1eT8qvFTf1zDRCaiDH05R8kMVqcAx52 +Vy1YpGcNSu8XRN69qSTpCb/WX0KCL4KoDtUIiH9ayPNPT+C1JA4MLvMce7mObzl60BA xpb6L84zpUwzrFQQs/G0We4GBa97DTfqH6+1oyr2BM1utfoak2O+bmdERHFnO6tPjkkH 1kiEkt9cwW88+5sCmJ0F57+OHuGvIphp+jRZ8GUODRCzI8y8R5o79beerndhsMyEGz+Y 3toyIeZHSH2t1i+kQk28vpztVda5Z6cWtBI3+Lz/M8B+ApKxT6nTkqi9OnFnloRYzSJ8 KlJQ== X-Gm-Message-State: APt69E2icwbNZ9vQ9Vqp5nED/11jWZ+3eX/cWT+WVT5k3fU4KlWDJL8h h4b5D5Kabe/LoG67abQ8ZmGpTvds X-Google-Smtp-Source: AAOMgpdF2dKCiEQVnkfbzaR46H5tXWzoavKGNvFhUOuNS8hr0Yv3gDD1Pz8Xr2otZz4y+14LkF2qwQ== X-Received: by 2002:a1c:91c4:: with SMTP id t187-v6mr3744470wmd.51.1530339081942; Fri, 29 Jun 2018 23:11:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 30 Jun 2018 08:10:31 +0200 Message-Id: <20180630061040.6018-39-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180630061040.6018-1-pbonzini@redhat.com> References: <20180630061040.6018-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22b Subject: [Qemu-devel] [PULL 38/47] hw/vfio: Use the IEC binary prefix definitions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Philippe Mathieu-Daud=C3=A9 It eases code review, unit is explicit. Patch generated using: $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/ and modified manually. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20180625124238.25339-38-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- hw/vfio/pci-quirks.c | 9 +++++---- hw/vfio/pci.c | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 061259b..481fd08 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -11,6 +11,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/units.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/range.h" @@ -1448,9 +1449,9 @@ static int vfio_igd_gtt_max(VFIOPCIDevice *vdev) ggms =3D 1 << ggms; } =20 - ggms *=3D 1024 * 1024; + ggms *=3D MiB; =20 - return (ggms / (4 * 1024)) * (gen < 8 ? 4 : 8); + return (ggms / (4 * KiB)) * (gen < 8 ? 4 : 8); } =20 /* @@ -1705,7 +1706,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *= vdev, int nr) igd->vdev =3D vdev; igd->index =3D ~0; igd->bdsm =3D vfio_pci_read_config(&vdev->pdev, IGD_BDSM, 4); - igd->bdsm &=3D ~((1 << 20) - 1); /* 1MB aligned */ + igd->bdsm &=3D ~((1 * MiB) - 1); /* 1MB aligned */ =20 memory_region_init_io(&quirk->mem[0], OBJECT(vdev), &vfio_igd_index_qu= irk, igd, "vfio-igd-index-quirk", 4); @@ -1752,7 +1753,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *= vdev, int nr) * config offset 0x5C. */ bdsm_size =3D g_malloc(sizeof(*bdsm_size)); - *bdsm_size =3D cpu_to_le64((ggms_mb + gms_mb) * 1024 * 1024); + *bdsm_size =3D cpu_to_le64((ggms_mb + gms_mb) * MiB); fw_cfg_add_file(fw_cfg_find(), "etc/igd-bdsm-size", bdsm_size, sizeof(*bdsm_size)); =20 diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 18c493b..a1577de 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -28,6 +28,7 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include "qemu/range.h" +#include "qemu/units.h" #include "sysemu/kvm.h" #include "sysemu/sysemu.h" #include "pci.h" @@ -1417,7 +1418,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) } =20 /* 2GB max size for 32-bit BARs, cannot double if already > 1G */ - if (vdev->bars[target_bar].size > (1 * 1024 * 1024 * 1024) && + if (vdev->bars[target_bar].size > 1 * GiB && !vdev->bars[target_bar].mem64) { error_setg(errp, "Invalid MSI-X relocation BAR %d, " "no space to extend 32-bit BAR", target_bar); --=20 1.8.3.1