From patchwork Sun Dec 1 16:09:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13889593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8F520D49771 for ; Sun, 1 Dec 2024 16:20:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHmer-0006FH-Mm; Sun, 01 Dec 2024 11:18:53 -0500 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 1tHmW7-0004dD-Pt for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:09:51 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHmW5-0000LD-UM for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:09:51 -0500 Received: by mail-pg1-x542.google.com with SMTP id 41be03b00d2f7-7fccc26ad01so177048a12.2 for ; Sun, 01 Dec 2024 08:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733069387; x=1733674187; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SByf2eHZKOlxWkzQnWPXy8cVLatcT0KnRddCPhNAor0=; b=Kfvx44rxKAqUMsDhsq0umO/hCDa0O5B7Ig9tJwZjbsxhA9nYEg6OoCqsgIhIkOBnQM PXx0V6CRiOmPaPuA7TCFD2yzbVF+G9KegtQf8+yXHqBlcKVsGYTG+DA+gsTvN8VUTYKp m+h6CY6ptydiUIgFHupz9USfthszrbpgnLrAnjhv7QpHSetfrPnFT27Q5jlRyANJcT64 Pfanapy88/V6p4pK5AcPlew8t8IBI/B+/A/8Nyut6s+4w8yXuV0ZRGWbva52sfoOPC8E 1z9dgh2srw9ZcIooQLZy+aACwyNyQO87aIyy9LHO5fE3jzk1+M5x8jcInObymmHXavQC 11rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733069387; x=1733674187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SByf2eHZKOlxWkzQnWPXy8cVLatcT0KnRddCPhNAor0=; b=BpQMgnH3Js+KOEIsbF4KKXmcVihBqMgFEo5c6O9DYXTV0MZ/2ImIQKoJd6LdaHm+6E A/QawVdSIFguwwkHlxpT0RccKXFlGJFkbOLP4KIXEFP+y9KC/Je+DBtdeAuens0K8vix bLGOs9oBxGEbP4tZG7LxwqbCwr/dBlcdX/3mEUZ2eBuhJZYBKqd501b+lJF52K6J376W X10lLsRYREIY0TbLSXrh+w2Bdvr9ItfteeoVM3Bshkck95ea4JIRFqh8S27WDwdXMV3i YltQyRfK/K8XttYL9xIdJZVJ3hU2BoiLnqLp+gUkHP5gJ9YDd2gX8ucYN0XDxk6zf+rl VnzQ== X-Gm-Message-State: AOJu0Yy3OuJacancPYKI3tbKc24J51VRnmaHTvlCbMr+aZ6uOh3Ppu4f Vpz0iZO5qKl8/GNDvCWxLK6WIH670dDLD8Y2N+c2OFXsbvPQUfepwo1KB393bLxa X-Gm-Gg: ASbGncse3wANvOjk4UtMuuwAL/z4HlGUZqz91gQn+xgSMRiUQv/EUiZvwJ7wRgi+2bo 6zaNEap/CtCj0LMAdRncAMrtUMIQ31IDjD/fL82im1OqBO+A09XPVqfYJOe5RvDZclnCqC9gjuT YgUg0/XVELYUTvDgykJKumjlRV2eDdjEZh1nS6kgDEeB9ekR45hC/DavMogoqftT6V/J//ggi5K 2kdOqtJwnKlIGkoIRdqDjFVUfBt6GYnSSPOE3k8obdsi0nwtDOIiZ+tJAQ= X-Google-Smtp-Source: AGHT+IH+OkOr2sr33ycUriIZJKVn7KVkQ0WJHMV29YUUAkRwqPh4c6ctFobS5hmAYVPk1kQf2Tjsmw== X-Received: by 2002:a05:6a20:4303:b0:1e0:da2f:9dc2 with SMTP id adf61e73a8af0-1e0e0c033dbmr33217355637.40.1733069387587; Sun, 01 Dec 2024 08:09:47 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7254176f47asm6785783b3a.43.2024.12.01.08.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 08:09:47 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH 1/8] vfio/igd: fix GTT stolen memory size calculation for gen 7 Date: Mon, 2 Dec 2024 00:09:31 +0800 Message-ID: <20241201160938.44355-2-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241201160938.44355-1-tomitamoeko@gmail.com> References: <20241201160938.44355-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x542.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: Sun, 01 Dec 2024 11:18:42 -0500 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Both intel documentation [1][2] and i915 driver shows GGMS represents GTT stolen memory size in multiple of 1MB, not 2MB starting from gen 8. [1] https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/3rd-gen-core-desktop-vol-2-datasheet.pdf [2] https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/4th-gen-core-family-desktop-vol-2-datasheet.pdf Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 4047f4f071..e40e601026 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -268,7 +268,7 @@ static int vfio_igd_gtt_max(VFIOPCIDevice *vdev) gmch = vfio_pci_read_config(&vdev->pdev, IGD_GMCH, sizeof(gmch)); ggms = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 6) { + if (gen > 7) { ggms = 1 << ggms; } @@ -678,7 +678,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) /* Determine the size of stolen memory needed for GTT */ ggms_mb = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 6) { + if (gen > 7) { ggms_mb = 1 << ggms_mb; } From patchwork Sun Dec 1 16:09:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13889591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 61DC2D49771 for ; Sun, 1 Dec 2024 16:20:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHmeq-0006F3-LE; Sun, 01 Dec 2024 11:18:52 -0500 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 1tHmW9-0004dP-QN for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:09:53 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHmW8-0000La-5j for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:09:53 -0500 Received: by mail-pf1-x443.google.com with SMTP id d2e1a72fcca58-7256a7a3d98so337016b3a.3 for ; Sun, 01 Dec 2024 08:09:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733069390; x=1733674190; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2FCjKkqD1YQ50P5Txv3hBWG+zfbM2d/VSBEmFOMVPzg=; b=GDrFgjGRreDSVOWoC7gjaiKO359VZofij071Rbw6FwI7oIVlgI+HK/Jcy95s1fsnB0 yOszTiVbiP5MN+sTD+ULDzjBQ6cnF6jg6mS+t2eDCrIx2yiiTs04qCKr+p7cYkGIpX4E aTVt0qcEYbm6v/qR7t4R3DSDf+IXMR6P/VTuVXyc6KBI6tp+edpLurCfr2xINoHbaw1j M2c48+XpYbqC8EwUSy9JC55hgfWJiYJ2wCA3ORUXc9GvQdw5PP2btWHmdvaU6LiAtu8Q gBZcDkt5d9riJbqocgajIlw0Cg2UsV9aRjefghLfHHasXdaQR3aVz3KnvZuzELzO3aus ZFQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733069390; x=1733674190; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2FCjKkqD1YQ50P5Txv3hBWG+zfbM2d/VSBEmFOMVPzg=; b=s1NQMhz6WNgFC56YzuODzSgJMbOakHAhS4opUXVmvhqzTozh3Ce5osqwurrHe/47SV y1+LXuGsaoINhuGXQVt0flTTbyRVOtUTJzRG491wrbDQ7idwXoag2PxXhqxST1FGlz2/ CQmx3B00+pcgsVs0aVgeMHTSo0DrUc4UdFvbj5xewbMk9X91Gz0HNkXOLLRR5BFG8fXj 29jzL+mid4lZaRZTMoLBJpM1z+FZuIrO2UZ2MFmMv8CRJgo08o9l8WEmML9uYy96GB6Y dfJhPuTA1Vxxo56MhgBn63qwbckRC7id0WRQOUvHbmXo67jUojKerusQq0fSzRfnKO11 1F0w== X-Gm-Message-State: AOJu0YwoWK7pwPrTuNI6c83YUNWhyGBmoIwW7VnstVeGqGFDr25JqqU/ JEkZu/3hHtRGD1QHae2M4CvYQs0pqrmyqWmDOCMCqNNr2uURPfYREYPI8459pQsH X-Gm-Gg: ASbGncslRFt6X9dabgWIRdHMaOG1vgLrG6ZJG5hn7+zIecoMf9A//F4Vr9TSOYP/tGg RZ5fe8n9sQezK40N/1pVV6zc+1+DnJeGJDLDN9c2NtAfrg99ITYVgijAdZ/PrMwKeaPcW1G0bD7 7PVVR2/lCORaoQXnwOt2eqPjJOf6TvAhkeWIHL6LtjZGmjcMJHFW9HNkNeeFd+G8EabvYOlGVER V9MS4omh6wmlJkUJ/CbSMAw76AhTExr/vSBYa9Ai626MZbZlzj6zJ1uw0Y= X-Google-Smtp-Source: AGHT+IH4Ilz7LnqGFNtq3FoqfEnb0d84XHXIvOWlzEEpb4YGpHD8injZMp1Y2eAi241gMFbFE/qNkg== X-Received: by 2002:a05:6a00:1396:b0:725:e6e:53f3 with SMTP id d2e1a72fcca58-7253003fb8bmr25936326b3a.12.1733069389912; Sun, 01 Dec 2024 08:09:49 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7254176f47asm6785783b3a.43.2024.12.01.08.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 08:09:49 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH 2/8] vfio/igd: canonicalize memory size calculations Date: Mon, 2 Dec 2024 00:09:32 +0800 Message-ID: <20241201160938.44355-3-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241201160938.44355-1-tomitamoeko@gmail.com> References: <20241201160938.44355-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=tomitamoeko@gmail.com; helo=mail-pf1-x443.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: Sun, 01 Dec 2024 11:18:42 -0500 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add helper functions igd_gtt_memory_size() and igd_stolen_size() for calculating GTT stolen memory and Data stolen memory size in bytes, and use macros to replace the hardware-related magic numbers for better readability. Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 101 ++++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 44 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index e40e601026..b449316ec0 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -116,6 +116,54 @@ typedef struct VFIOIGDQuirk { #define IGD_BDSM 0x5c /* Base Data of Stolen Memory */ #define IGD_BDSM_GEN11 0xc0 /* Base Data of Stolen Memory of gen 11 and later */ +#define IGD_GMCH_GEN6_GMS_SHIFT 3 +#define IGD_GMCH_GEN6_GMS_MASK 0x1f +#define IGD_GMCH_GEN6_GGMS_SHIFT 8 +#define IGD_GMCH_GEN6_GGMS_MASK 0x3 +#define IGD_GMCH_GEN8_GMS_SHIFT 8 +#define IGD_GMCH_GEN8_GMS_MASK 0xff +#define IGD_GMCH_GEN8_GGMS_SHIFT 6 +#define IGD_GMCH_GEN8_GGMS_MASK 0x3 + +static uint64_t igd_gtt_memory_size(int gen, uint16_t gmch) +{ + uint64_t ggms; + + if (gen < 8) { + ggms = (gmch >> IGD_GMCH_GEN6_GGMS_SHIFT) & IGD_GMCH_GEN6_GGMS_MASK; + } else { + ggms = (gmch >> IGD_GMCH_GEN8_GGMS_SHIFT) & IGD_GMCH_GEN8_GGMS_MASK; + ggms *= 2; + } + + return ggms * MiB; +} + +static uint64_t igd_stolen_memory_size(int gen, uint32_t gmch) +{ + uint64_t gms; + + if (gen < 8) { + gms = (gmch >> IGD_GMCH_GEN6_GMS_SHIFT) & IGD_GMCH_GEN6_GMS_MASK; + } else { + gms = (gmch >> IGD_GMCH_GEN8_GMS_SHIFT) & IGD_GMCH_GEN8_GMS_MASK; + } + + if (gen < 9) { + if (gms < 0x10) { + return gms * 32 * MiB; + } + } else { + if (gms < 0xf0) { + return gms * 32 * MiB; + } else { + return (gms - 0xf0 + 1) * 4 * MiB; + } + } + + error_report("Unsupported IGD GMS value 0x%lx", gms); + return 0; +} /* * The rather short list of registers that we copy from the host devices. @@ -264,17 +312,10 @@ static int vfio_pci_igd_lpc_init(VFIOPCIDevice *vdev, static int vfio_igd_gtt_max(VFIOPCIDevice *vdev) { uint32_t gmch = vfio_pci_read_config(&vdev->pdev, IGD_GMCH, sizeof(gmch)); - int ggms, gen = igd_gen(vdev); - - gmch = vfio_pci_read_config(&vdev->pdev, IGD_GMCH, sizeof(gmch)); - ggms = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 7) { - ggms = 1 << ggms; - } - - ggms *= MiB; + int gen = igd_gen(vdev); + uint64_t ggms_size = igd_gtt_memory_size(gen, gmch); - return (ggms / (4 * KiB)) * (gen < 8 ? 4 : 8); + return (ggms_size / (4 * KiB)) * (gen < 8 ? 4 : 8); } /* @@ -481,30 +522,6 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); } -static int igd_get_stolen_mb(int gen, uint32_t gmch) -{ - int gms; - - if (gen < 8) { - gms = (gmch >> 3) & 0x1f; - } else { - gms = (gmch >> 8) & 0xff; - } - - if (gen < 9) { - if (gms > 0x10) { - error_report("Unsupported IGD GMS value 0x%x", gms); - return 0; - } - return gms * 32; - } else { - if (gms < 0xf0) - return gms * 32; - else - return (gms - 0xf0) * 4 + 4; - } -} - void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) { g_autofree struct vfio_region_info *rom = NULL; @@ -514,7 +531,8 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) VFIOQuirk *quirk; VFIOIGDQuirk *igd; PCIDevice *lpc_bridge; - int i, ret, ggms_mb, gms_mb = 0, gen; + int i, ret, gen; + uint64_t ggms_size, gms_size; uint64_t *bdsm_size; uint32_t gmch; uint16_t cmd_orig, cmd; @@ -676,13 +694,8 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); - /* Determine the size of stolen memory needed for GTT */ - ggms_mb = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 7) { - ggms_mb = 1 << ggms_mb; - } - - gms_mb = igd_get_stolen_mb(gen, gmch); + ggms_size = igd_gtt_memory_size(gen, gmch); + gms_size = igd_stolen_memory_size(gen, gmch); /* * Request reserved memory for stolen memory via fw_cfg. VM firmware @@ -693,7 +706,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) * config offset 0x5C. */ bdsm_size = g_malloc(sizeof(*bdsm_size)); - *bdsm_size = cpu_to_le64((ggms_mb + gms_mb) * MiB); + *bdsm_size = cpu_to_le64(ggms_size + gms_size); fw_cfg_add_file(fw_cfg_find(), "etc/igd-bdsm-size", bdsm_size, sizeof(*bdsm_size)); @@ -744,5 +757,5 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) vdev->vbasedev.name); } - trace_vfio_pci_igd_bdsm_enabled(vdev->vbasedev.name, ggms_mb + gms_mb); + trace_vfio_pci_igd_bdsm_enabled(vdev->vbasedev.name, *bdsm_size / MiB); } From patchwork Sun Dec 1 16:09:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13889588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AD739D4977D for ; Sun, 1 Dec 2024 16:19:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHmeo-0006E1-DQ; Sun, 01 Dec 2024 11:18:50 -0500 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 1tHmWB-0004eg-Mn for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:09:55 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHmWA-0000Lz-Cx for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:09:55 -0500 Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-215909152c5so1417205ad.3 for ; Sun, 01 Dec 2024 08:09:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733069392; x=1733674192; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0zc2flP+weLaeacCQlZ9Rqxnlz3dYxcJBhurwoN/GxU=; b=HxW8mrqnFI3xI4AbJl6ylM5jIoJ4pg4RuBserX5N+n0CkHnTHCNnvNEKMBBPIDah2V FI533aqwD6Cy3zPY6iX4PWSK0ss66cr6VLGS5IMRHajU6wKp6DYlNZxyZPSyZFuHXNWu j5sqSCnKwd1fdSrbUg+sOJ38QwBuxS/qwB38UMQIXhYA0y+CkZ9vjG0M/KG20wdIJ4YQ ezwyPXgPmiWgM2ubr9ReAcxPtV5eHEnvDcQXG1SG+rbEh2LDjofiJUcprmRQgrP5anyx oVzkQDhlcAJ3GAUdgp/LglNwIdso65qNr+kQybYrr951tmRTQIg4EDodRhcmtcmTkXbU np5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733069392; x=1733674192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0zc2flP+weLaeacCQlZ9Rqxnlz3dYxcJBhurwoN/GxU=; b=cTLcrtmYawJbWRHXqkFK0gaMFAEXDW28JQ9HHGTP6W6h6zxl6F3RZTHRAOt3uOSXPE uBlu2hP+eekoRrphvcZh0wsuVj4NZDXe9rEdHLG0YSGb/qe0m3MdIEpxO9SvGUoD3lop L0OyGb/W7jK22FoswUNwZWK5PrUh4NsKaJ8POP8S75cDd+xBIfTXj2KyfQDoEkbrcNbe qzkCsHmFvXFl07Kg6I8b7bsBHU1UkRBlNtPBwO4rkvmGTuXfJ0LBRhOZ1Balo/suC1L+ CN1gkxnQnN1iqb+8pa/n3nUQob/pPTafHr3Ofjs+fhi87YQXk3T+wxOoISJnL+BisDWa NM1Q== X-Gm-Message-State: AOJu0YzS2jiegVyslVLymIKXwMQW+bsuHPOwNBnt+PtKvUgJZaqxyTrB f6B9E/G2DHeCuYesVq23TcOnQo4D4y7NIHd4tCNHsAREFFjqjL/PCrAM4UH892wB X-Gm-Gg: ASbGncsgZIPzZofS8h1LEhSFyQEZ3Za1tzv4o2EjAITk1ZSn6JEUudYsUqug0fHldSs +fiOOYdDBkGihUnlMRcCJZHshMTCKjw5TQGyyy+g7sj4Ls8V9qJr2Z5245JA1thEzQqhid1RxYt il7Iw6liJTarGBJpqdGYquvml7Spi5vIRj+mIDZfpP0B+/hu4ifuBXO/lZIsOfgk5p0dGED0hXZ eOQdIt15sOUNeLkCdx12xlkB86fSNjouvITYQ/1P1i3KndnE3Wm4kj0HG8= X-Google-Smtp-Source: AGHT+IEBP9w7/tfQUbNMxZF9gAou0F5abZDZKGUjnGU1qtijxczZvRCHdZ2l+qtCY+fRyhtmCcbxZA== X-Received: by 2002:a17:902:cf05:b0:215:7f94:2b8 with SMTP id d9443c01a7336-2157f94089bmr44583085ad.24.1733069392301; Sun, 01 Dec 2024 08:09:52 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7254176f47asm6785783b3a.43.2024.12.01.08.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 08:09:52 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH 3/8] vfio/igd: remove unsupported device ids Date: Mon, 2 Dec 2024 00:09:33 +0800 Message-ID: <20241201160938.44355-4-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241201160938.44355-1-tomitamoeko@gmail.com> References: <20241201160938.44355-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=tomitamoeko@gmail.com; helo=mail-pl1-x641.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: Sun, 01 Dec 2024 11:18:42 -0500 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Since e433f208973f ("vfio/igd: return an invalid generation for unknown devices"), the default return of igd_gen() was changed to unsupported. There is no need to filter out those unsupported devices. Signed-off-by: Tomita Moeko Reviewed-by: Alex Williamson Reviewed-by: Corvin Köhne --- hw/vfio/igd.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index b449316ec0..8f300498e4 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -64,16 +64,6 @@ static int igd_gen(VFIOPCIDevice *vdev) } switch (vdev->device_id & 0xff00) { - /* Old, untested, unavailable, unknown */ - case 0x0000: - case 0x2500: - case 0x2700: - case 0x2900: - case 0x2a00: - case 0x2e00: - case 0x3500: - case 0xa000: - return -1; /* SandyBridge, IvyBridge, ValleyView, Haswell */ case 0x0100: case 0x0400: From patchwork Sun Dec 1 16:09:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13889585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 888C8D49771 for ; Sun, 1 Dec 2024 16:19:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHmes-0006Fx-U6; Sun, 01 Dec 2024 11:18:54 -0500 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 1tHmWF-0004gJ-Rn for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:10:01 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHmWD-0000MQ-MP for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:09:59 -0500 Received: by mail-pf1-x441.google.com with SMTP id d2e1a72fcca58-724d8422dbaso2825773b3a.0 for ; Sun, 01 Dec 2024 08:09:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733069394; x=1733674194; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RMyozJ6DBXdJ3uspS/5iXrrtagliYxbLSROJVV3WvzM=; b=Eg8eiNC9XVLO9J6B16aRMdiWWq7sLxXHNF6bPef7cGlPzyefVz6iKnFzv0d7uK2blH dFtwYEEYxBeVifmus3rqbbfZP5wZNlKd4Nb+8+NClCj4EgUApC2lYvyU3fIQXyu9zcFo gHg6MKJFKynABCqiSravreKubDqW8F9xP173/7hywliJK2YQSsmW4RL96OGKbbc903iN 2teavUcSbpPfgNZ9d9nywp3Y/XPs0Z1x2uWfjBtD/bVa5tEivjeDnlxEUE+jxRRCRQDM otJMErkz8qPl0SR258pa2aQwqDL7ce75BcjG/P//Z/K4jEDhjdxsIEBwur6MUfP3J+lc wsmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733069394; x=1733674194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RMyozJ6DBXdJ3uspS/5iXrrtagliYxbLSROJVV3WvzM=; b=TsO6Emh/sE+BmDzgFpObTn4iBFCMO4/zrzhzdr2WGlHunR80EqYid89tGRw/SEm3Ko TRn4gjulSSPYIb8V0xKWEcOuPNCNHgcBen6+uNOxsiBylAxGKYKhEsFmnrmpvmqnhpmf zqAdaC6nxHOPYpwa2T/SQ6sWPxhZm/aP17DhoaSg+9xB9zyCKrXFYEPMI4Gkmd8ptLIl ExBovVuo/zBRoDYD9QPFurrJD3sXVqO/1GYHL/VFoW51EnDX8jglvBz//Rcc4e7ipmuG +JNcd2xpx5W7wDLK0EvnAKlOm68N79zfeYnZzwqUeYFMUqVPWDFEKX93/DovoupZkTFe TO0Q== X-Gm-Message-State: AOJu0YyyzyMDEZ6xnENZ/rCG7qM5Dx0bFrfzqGzqQkUsDzJHtNkPVOpq 80Jl//w+kOP2TeBC/ApHL4YO7RzN2hC77r1/W7KlMnYTCpo6qxem48JteGk2x+oM X-Gm-Gg: ASbGncuBdsNExDLRy6nNk5pgiswLKd9k/ev+5KO1aTJimZo5Qi7ku4hkaNokskus30D IxLFIlNh75du+kJJmcZaqhHqYWwE6bOzyv+QTzB5R70H4VMfTGbkSFyGl10gzi4+ajCCv0ue0UD HBvv0DrwpXC+DuGVk4VJFupAk7HHQpFN8EKq+41pSlQRcU7Z6DV3F2nmCOeJzhbKch+H5oFooKO +BG1R+0BJxJxBRv0qGoNJqdWrcYOPx4gP6C3e+2EaUU26o98BXYxiXh8BI= X-Google-Smtp-Source: AGHT+IF/IvWq5CHeQmALXaR2tOpcd5B79LKQAfEDozssy8Jv5PG/NSGyx+h9vyp/u7rSURjokrlnhg== X-Received: by 2002:a05:6a00:c8b:b0:71e:cb:e7bf with SMTP id d2e1a72fcca58-7253013e6aamr26713943b3a.18.1733069394593; Sun, 01 Dec 2024 08:09:54 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7254176f47asm6785783b3a.43.2024.12.01.08.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 08:09:54 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH 4/8] vfio/igd: align generation with i915 kernel driver Date: Mon, 2 Dec 2024 00:09:34 +0800 Message-ID: <20241201160938.44355-5-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241201160938.44355-1-tomitamoeko@gmail.com> References: <20241201160938.44355-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=tomitamoeko@gmail.com; helo=mail-pf1-x441.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: Sun, 01 Dec 2024 11:18:42 -0500 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Define the igd device generations according to i915 kernel driver to avoid confusion, and adjust comment placement to clearly reflect the relationship between ids and devices. Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 8f300498e4..71342863d6 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -59,33 +59,29 @@ */ static int igd_gen(VFIOPCIDevice *vdev) { - if ((vdev->device_id & 0xfff) == 0xa84) { - return 8; /* Broxton */ + if ((vdev->device_id & 0xffe) == 0xa84) { + return 9; /* Broxton/Apollo Lake, Gemini Lake */ } switch (vdev->device_id & 0xff00) { - /* SandyBridge, IvyBridge, ValleyView, Haswell */ - case 0x0100: - case 0x0400: - case 0x0a00: - case 0x0c00: - case 0x0d00: - case 0x0f00: + case 0x0100: /* SandyBridge, IvyBridge */ return 6; - /* BroadWell, CherryView, SkyLake, KabyLake */ - case 0x1600: - case 0x1900: - case 0x2200: - case 0x5900: + case 0x0400: /* Haswell */ + case 0x0a00: /* Haswell */ + case 0x0c00: /* Haswell */ + case 0x0d00: /* Haswell */ + case 0x0f00: /* Valleyview/Bay Trail */ + return 7; + case 0x1600: /* Broadwell */ + case 0x2200: /* Cherryview */ return 8; - /* CoffeeLake */ - case 0x3e00: + case 0x1900: /* Skylake */ + case 0x5900: /* Kaby Lake */ + case 0x3e00: /* Coffee Lake */ return 9; - /* ElkhartLake */ - case 0x4500: + case 0x4500: /* Elkhart Lake */ return 11; - /* TigerLake */ - case 0x9A00: + case 0x9A00: /* Tiger Lake */ return 12; } From patchwork Sun Dec 1 16:09:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13889587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AAF1DD4977C for ; Sun, 1 Dec 2024 16:19:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHmer-0006Fc-Tw; Sun, 01 Dec 2024 11:18:54 -0500 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 1tHmWG-0004gK-3f for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:10:01 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHmWE-0000NF-Of for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:09:59 -0500 Received: by mail-pf1-x443.google.com with SMTP id d2e1a72fcca58-724d57a9f7cso2779275b3a.3 for ; Sun, 01 Dec 2024 08:09:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733069397; x=1733674197; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q2dZjlop092atRpGDfrU0RR8pyuyR4PiiokKniietfo=; b=iFLdVaY7LhzRb4VwIIPKxBELX39xdOeaU4Vv5MNDrRoQCVtlqmHZZe0vxCgVQFnpIB nE1+iZhNDEToLNhfz3wyjUFSj+L7oDti5O3rpfB0D6nsGHtn/vwRksrHY9G9jaKLk2f1 tg8OqDH854wDRXlDlofMJVQrpVu3Elz8bBRVATflieidnWrS5VkrDEFxKDpYxhJdbccb klEInBdeQ9ng8b7jgyfAmh6beb8QYn0o55d0oLV7O4KKs+BPknkNDy52gxCRlG4SQ+Hz ZM4eETsfPTlJ3dehbuOvnDlaJJciYaFvHSUhq3RQ6pl9A1FjYajwmTK3RIcn3o1a9MqH 9UDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733069397; x=1733674197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q2dZjlop092atRpGDfrU0RR8pyuyR4PiiokKniietfo=; b=s3cclQVUgKybB7KSTesHxIWXnhM900ex7MbjKefQDbHeLjSueitmb4sVCIQ59fBbZ4 qNOY6GAODFTCnrZwGGs+5XhatWIM1R3nV4CazbTf7SI/YaH6IUiGzS2RvssT7BExLFk5 tsOs3fdox0WX4G0j15e1UNkNocAbeGhn5k2FYOx7klcB8MI2/kd7fEXTTC4bMujqk/ca Pwqxzw5H7ZofMBo/jG4Vi5tdHPFnQHQfVpXYIpTYmz9jt9oLnPfQsdRDjlEB14e5iwvW qKJvBL0/GjNrRRbbI+WsR2f/CT2rCKybpxbKwf3Rrd4+5V7aUXQ12idxk7lZS88kFAY3 W/aw== X-Gm-Message-State: AOJu0YyvVvNpXewep/JiGZKffIZmj9kU2ki1VJdB0KpBF+ej6ZdvJwQP nANIDxjh0HvO2erHuSRyTV1g3QwxtZgLvnjUIIBUFXcDSufQoyH88YLFyEE9nVJf X-Gm-Gg: ASbGncuiGPYQwrSgKqQOkVytoSy1fs7GppthmB/Iaktc/6pF5/0gF6Sj8XveRHRTeih PFLC7Jk79jqUmV6+2KzBrdlNOXHwjpAISZTaGhTFkvPtWRAnN/Jla1hBLeq5ZvOymOOxHxJqPWn 6U9jTNk0PlOiDCt883c4NkaDzzymu1Ae2iX4801blvjLSEVhCQWd0O5aidrfYSYDKbEGWVL62ji ZmK8I/H2wOPrvEzg0QH0TMtLdmb6NgF6V5vwIM5ygJlhTc1U5zKvYZ2n9k= X-Google-Smtp-Source: AGHT+IG452zMVKZIO3JhaB+2/7X5rlwOuiMkKQ6H+q1jxZno+K/QpqPdfr01iOeUNuq2z50XNZc0lQ== X-Received: by 2002:a05:6a00:4f93:b0:71e:4786:98ee with SMTP id d2e1a72fcca58-7253015eecdmr27963431b3a.21.1733069397149; Sun, 01 Dec 2024 08:09:57 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7254176f47asm6785783b3a.43.2024.12.01.08.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 08:09:56 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH 5/8] vfio/igd: add Alder/Raptor/Rocket/Ice/Jasper Lake device ids Date: Mon, 2 Dec 2024 00:09:35 +0800 Message-ID: <20241201160938.44355-6-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241201160938.44355-1-tomitamoeko@gmail.com> References: <20241201160938.44355-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=tomitamoeko@gmail.com; helo=mail-pf1-x443.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: Sun, 01 Dec 2024 11:18:42 -0500 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org All gen 11 and 12 igd devices have 64 bit BDSM register at 0xC0 in its config space, add them to the list to support igd passthrough on Alder/ Raptor/Rocket/Ice/Jasper Lake platforms. Tested legacy mode of igd passthrough works properly on both linux and windows guests with AlderLake-S GT1 (8086:4680). Signed-off-by: Tomita Moeko Reviewed-by: Corvin Köhne --- hw/vfio/igd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 71342863d6..a86faf2fa9 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -79,9 +79,14 @@ static int igd_gen(VFIOPCIDevice *vdev) case 0x5900: /* Kaby Lake */ case 0x3e00: /* Coffee Lake */ return 9; + case 0x8A00: /* Ice Lake */ case 0x4500: /* Elkhart Lake */ + case 0x4E00: /* Jasper Lake */ return 11; case 0x9A00: /* Tiger Lake */ + case 0x4C00: /* Rocket Lake */ + case 0x4600: /* Alder Lake */ + case 0xA700: /* Raptor Lake */ return 12; } From patchwork Sun Dec 1 16:09:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13889592 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8E0B9D49779 for ; Sun, 1 Dec 2024 16:20:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHmep-0006ER-57; Sun, 01 Dec 2024 11:18:51 -0500 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 1tHmWJ-0004i5-Tq for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:10:04 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHmWH-0000QS-MS for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:10:03 -0500 Received: by mail-pf1-x441.google.com with SMTP id d2e1a72fcca58-723f37dd76cso2908600b3a.0 for ; Sun, 01 Dec 2024 08:10:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733069400; x=1733674200; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+xHPgrr8qcitMTkySx0BnFAYVdeofMUqMuEPagNjjfQ=; b=eyH7pv+TBTnDK/EJHCMoFYAe3ZCpYu/xx/AF2sOFvYTEG7aRzDUE9h5cnE/6YjTWyK R9iBMiV3UD5cXqHhmjZb17+enml5S1FowWlIKb+8VZonE6wTKoz9c1tun7wW3Mk8chZE EOJXJM4bWc1RXrgFaw45RuU6sTaDoxSSBLWjnjBwsUI1hpzIJILWL7Cv+8Osef3t2aaj bFYXWxqN3koEqDapfQrCBrpKEPumsNILcuwKswLuGovegqjyMsdrGmLhDyGoKGQdXjRN o1jWCIrNatQDqSHFwxZSOMQz1g9yfaTK4mfp0yLM8q95i4P3WBjx7l+qCTQ0jtVhUKzh TdLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733069400; x=1733674200; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+xHPgrr8qcitMTkySx0BnFAYVdeofMUqMuEPagNjjfQ=; b=NmJc41dpd1C0umi1i84TSPPSxDpCqevyNrLZjJvTj4DD3EV0ONIVkw6CqFTMlp6P0t DioVBhBip+8rJ80/xEkDGW7OjBaD4cC1RvcXcL2aYUT6sT4EytD4YPmpWxXQVY1Opu0Y CmQcAmEvgKbvbzGTRsvmuYPZay6t0pYJ6xKTb6l5IPeieXimwkAhevHkD66ptX8PSUXq MBR3iIEQ877KVHDpezH+kwdX7Md4d+w2sLpU5Q8y6aBczpgohQp1AEVR7ShH53UVHezE R5kFjLrDVt7+9qSraDSSb65LFHvHhTnKEL3T0YZw3N56Ftz5E6mECDjFtBDbetBmZL7u v9jQ== X-Gm-Message-State: AOJu0YygFCsRfPv4R9ytfpysIFWYhT57t15yN5wrIS/YWtrSrSUIZSyo AJifC/55fMBtkVMfxq8ScxkvLodiR/EONhGF/aMiKoLwObxto5/bq+HnhcOe8DLX X-Gm-Gg: ASbGncsQqj1au/wUBO3X9+wbAufN7TihH74JYVhv2t5meokCJNI3kSXcEErCxC9h3pC SeolS0SdkNff/xTi16AE3/x1OJS6+H7SvR8n+MKN12R7lArDW2qZP7TFHB6XptEqbGNAK5ELEKc j1fuVtxEWrJbwOGZyLHk3yKNeosS6tWIt3AfWKMhyTET7rmuNPXKR/IbWxJWjFA+RwlcIbqy3d8 riQMViYAhxcW5b0ToHHrnMqtsYQDm0X/sqBBMEq2HntnKwyhw3Mys37ocQ= X-Google-Smtp-Source: AGHT+IHjOAA4j0Pi/YpwJJaynPCMGXCs9Ny5HGgb8kAtO0HfmxM6BLAtmn2DOuyNLriDf3bogRHxiA== X-Received: by 2002:a05:6a00:3d0f:b0:724:46eb:c38f with SMTP id d2e1a72fcca58-7253017776fmr26437912b3a.25.1733069399648; Sun, 01 Dec 2024 08:09:59 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7254176f47asm6785783b3a.43.2024.12.01.08.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 08:09:59 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH 6/8] vfio/igd: emulate GGC register in mmio bar0 Date: Mon, 2 Dec 2024 00:09:36 +0800 Message-ID: <20241201160938.44355-7-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241201160938.44355-1-tomitamoeko@gmail.com> References: <20241201160938.44355-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=tomitamoeko@gmail.com; helo=mail-pf1-x441.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: Sun, 01 Dec 2024 11:18:42 -0500 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The GGC register at 0x50 of pci config space is a mirror of the same register at 0x108040 of mmio bar0 [1]. i915 driver also reads that register from mmio bar0 instead of config space. As GGC is programmed and emulated by qemu, the mmio address should also be emulated, in the same way of BDSM register. A macro is defined to simplify the declaration of MemoryRegionOps for a register mirrored to pcie config space. [1] 4.1.28, 12th Generation Intel Core Processors Datasheet Volume 2 https://www.intel.com/content/www/us/en/content-details/655259 Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 67 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index a86faf2fa9..07700dce30 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -415,16 +415,9 @@ static const MemoryRegionOps vfio_igd_index_quirk = { .endianness = DEVICE_LITTLE_ENDIAN, }; -#define IGD_BDSM_MMIO_OFFSET 0x1080C0 - -static uint64_t vfio_igd_quirk_bdsm_read(void *opaque, - hwaddr addr, unsigned size) +static uint64_t vfio_igd_pci_config_read(VFIOPCIDevice *vdev, uint64_t offset, + unsigned size) { - VFIOPCIDevice *vdev = opaque; - uint64_t offset; - - offset = IGD_BDSM_GEN11 + addr; - switch (size) { case 1: return pci_get_byte(vdev->pdev.config + offset); @@ -442,14 +435,12 @@ static uint64_t vfio_igd_quirk_bdsm_read(void *opaque, return 0; } -static void vfio_igd_quirk_bdsm_write(void *opaque, hwaddr addr, - uint64_t data, unsigned size) -{ - VFIOPCIDevice *vdev = opaque; - uint64_t offset; - - offset = IGD_BDSM_GEN11 + addr; +#define IGD_GGC_MMIO_OFFSET 0x108040 +#define IGD_BDSM_MMIO_OFFSET 0x1080C0 +static void vfio_igd_pci_config_write(VFIOPCIDevice *vdev, uint64_t offset, + uint64_t data, unsigned size) +{ switch (size) { case 1: pci_set_byte(vdev->pdev.config + offset, data); @@ -464,17 +455,35 @@ static void vfio_igd_quirk_bdsm_write(void *opaque, hwaddr addr, pci_set_quad(vdev->pdev.config + offset, data); break; default: - hw_error("igd: unsupported read size, %u bytes", size); + hw_error("igd: unsupported write size, %u bytes", size); break; } } -static const MemoryRegionOps vfio_igd_bdsm_quirk = { - .read = vfio_igd_quirk_bdsm_read, - .write = vfio_igd_quirk_bdsm_write, - .endianness = DEVICE_LITTLE_ENDIAN, +#define VFIO_IGD_QUIRK_MIRROR_REG(reg, name) \ +static uint64_t vfio_igd_quirk_read_##name(void *opaque, \ + hwaddr addr, unsigned size) \ +{ \ + VFIOPCIDevice *vdev = opaque; \ + return vfio_igd_pci_config_read(vdev, reg + addr, size); \ +} \ + \ +static void vfio_igd_quirk_write_##name(void *opaque, hwaddr addr, \ + uint64_t data, unsigned size) \ +{ \ + VFIOPCIDevice *vdev = opaque; \ + vfio_igd_pci_config_write(vdev, reg + addr, data, size); \ +} \ + \ +static const MemoryRegionOps vfio_igd_quirk_mirror_##name = { \ + .read = vfio_igd_quirk_read_##name, \ + .write = vfio_igd_quirk_write_##name, \ + .endianness = DEVICE_LITTLE_ENDIAN, \ }; +VFIO_IGD_QUIRK_MIRROR_REG(IGD_GMCH, ggc) +VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM_GEN11, bdsm) + void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) { VFIOQuirk *quirk; @@ -501,13 +510,21 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) return; } - quirk = vfio_quirk_alloc(1); + quirk = vfio_quirk_alloc(2); quirk->data = vdev; - memory_region_init_io(&quirk->mem[0], OBJECT(vdev), &vfio_igd_bdsm_quirk, - vdev, "vfio-igd-bdsm-quirk", 8); + memory_region_init_io(&quirk->mem[0], OBJECT(vdev), + &vfio_igd_quirk_mirror_ggc, vdev, + "vfio-igd-ggc-quirk", 2); + memory_region_add_subregion_overlap(vdev->bars[0].region.mem, + IGD_GGC_MMIO_OFFSET, &quirk->mem[0], + 1); + + memory_region_init_io(&quirk->mem[1], OBJECT(vdev), + &vfio_igd_quirk_mirror_bdsm, vdev, + "vfio-igd-bdsm-quirk", 8); memory_region_add_subregion_overlap(vdev->bars[0].region.mem, - IGD_BDSM_MMIO_OFFSET, &quirk->mem[0], + IGD_BDSM_MMIO_OFFSET, &quirk->mem[1], 1); QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); From patchwork Sun Dec 1 16:09:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13889586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A8816D4977B for ; Sun, 1 Dec 2024 16:19:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHmej-0006Am-AG; Sun, 01 Dec 2024 11:18:45 -0500 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 1tHmWL-0004l0-UR for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:10:07 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHmWK-0000as-5F for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:10:05 -0500 Received: by mail-pg1-x543.google.com with SMTP id 41be03b00d2f7-7fbc29b3145so3112140a12.0 for ; Sun, 01 Dec 2024 08:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733069402; x=1733674202; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6tueBpIYPosweRTFKRGJqnAbIWV+bdPvEzW06gBaClo=; b=RwrA3Q6k69Vlc2Vj7SavtsdUx/s0Fr/kSUya4UD9fVhH83YCZBrPMX2lvrbpMYlS5h 5sCDDHFRfEibcqZHwmfkIORz/mn+abeaJPm72z4X6/fMrh7MW2j1AXU0gOUE/7eABumJ VmdVakyl5sdY05PjOhwtb8F3vLNjbJ82QlHIpX4TP3/6kZMSMT61M3078OmiQh0ASam6 lQNK2GlIHhSumvQNEI36syLdM6QHY0Jpi1i/ubMnAJEUDTXRWqmDbDHJXTpcDjo3LYP+ kFan3Uriiqvfb9cYkiadnlQJd1zMlemqvTw4FiqssUBPI7LbOcSg8zT4cjz1O/pAWkEY 3wdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733069402; x=1733674202; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6tueBpIYPosweRTFKRGJqnAbIWV+bdPvEzW06gBaClo=; b=PKcSbxzZp9UyXGLgLveDd2JNPzzaBL0CSFxEgoPqGV36eoMtFSbEfhJDO0csvYZl1K puj/rx1I7JaeBrOVZnKHDI1rVHbuh+wTwkqoQ+QI5dtY2vmosLMpA8Jm+0xAhyTbkm8/ QwqytruPrYfRiKs+xktjfbfCaPkZdZrNCb4B8DgfzBjEsOTBu85Nur8vRwa0qEjmHI2p O1wNeo6OfheTTPfcgdqBIGLFU7J5Eu14CVOv2+9edYYGbjmM93W4UNPC0CgL61tCf4b9 5Z64qVE7jKw+ydrRd+UssrbzQ9cdiZ6Qtco6Zfs5v6NxL04RGMcDteOIKmUdzVQNuwCR zYJg== X-Gm-Message-State: AOJu0YzDsrfTfKZOlEujNvduEiFaOH+Pfuilnco5g9UJj9MLhVJo7TM0 S1eWzQrxYfVZ0wSBH3wxQz+MR20d0dOO1DEwaBAOuicYVGf4NJhhBNlGV6fk4wrm X-Gm-Gg: ASbGncvXSqs7SmIzD9hiCzAkPhMgRs1NL7Dh/Phk6GBygl+czqN5EW8R5yA9AuaZPBL l3vFnwWBFJjP950rWjkGj+gco6KTRr7itSALitRLCqW1PVoYv7fINrVn3mqIRUz99ejCbh3P+Qh jKWJuIWsryRAQRVjoTjFKiwwrh519U/zD56thi7eS8aE5bnALhpW/Ssj67/7d4+sS3u3j95VBUF zPv0uUreOqPrF81mdOFhP1DWcdvOrPUAVsWaiIh/cv7pMBl+9ncYTs7DfY= X-Google-Smtp-Source: AGHT+IF1/MrkmyKDLZLiIEUl6wJ9c6krgys9gLqcLjRrFJn3nYjCG1QNNE06M3efbTLsKQEnuAijhA== X-Received: by 2002:a05:6a20:9185:b0:1e0:c166:18ba with SMTP id adf61e73a8af0-1e0ec841220mr21690295637.12.1733069402049; Sun, 01 Dec 2024 08:10:02 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7254176f47asm6785783b3a.43.2024.12.01.08.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 08:10:01 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH 7/8] vfio/igd: emulate BDSM in mmio bar0 for gen 6-10 devices Date: Mon, 2 Dec 2024 00:09:37 +0800 Message-ID: <20241201160938.44355-8-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241201160938.44355-1-tomitamoeko@gmail.com> References: <20241201160938.44355-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x543.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: Sun, 01 Dec 2024 11:18:43 -0500 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org A recent commit in i915 driver [1] claims the BDSM register at 0x1080c0 of mmio bar0 has been there since gen 6. Mirror this register to the 32 bit BDSM register at 0x5c in pci config space for gen6-10 devices. [1] https://patchwork.freedesktop.org/patch/msgid/20240202224340.30647-7-ville.syrjala@linux.intel.com Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 07700dce30..3fd822241d 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -482,7 +482,8 @@ static const MemoryRegionOps vfio_igd_quirk_mirror_##name = { \ }; VFIO_IGD_QUIRK_MIRROR_REG(IGD_GMCH, ggc) -VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM_GEN11, bdsm) +VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM, bdsm) +VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM_GEN11, bdsm64) void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) { @@ -506,7 +507,7 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) * into MMIO space and read from MMIO space by the Windows driver. */ gen = igd_gen(vdev); - if (gen < 11) { + if (gen < 6) { return; } @@ -520,12 +521,21 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) IGD_GGC_MMIO_OFFSET, &quirk->mem[0], 1); - memory_region_init_io(&quirk->mem[1], OBJECT(vdev), - &vfio_igd_quirk_mirror_bdsm, vdev, - "vfio-igd-bdsm-quirk", 8); - memory_region_add_subregion_overlap(vdev->bars[0].region.mem, - IGD_BDSM_MMIO_OFFSET, &quirk->mem[1], - 1); + if (gen < 11) { + memory_region_init_io(&quirk->mem[1], OBJECT(vdev), + &vfio_igd_quirk_mirror_bdsm, vdev, + "vfio-igd-bdsm-quirk", 4); + memory_region_add_subregion_overlap(vdev->bars[0].region.mem, + IGD_BDSM_MMIO_OFFSET, + &quirk->mem[1], 1); + } else { + memory_region_init_io(&quirk->mem[1], OBJECT(vdev), + &vfio_igd_quirk_mirror_bdsm64, vdev, + "vfio-igd-bdsm-quirk", 8); + memory_region_add_subregion_overlap(vdev->bars[0].region.mem, + IGD_BDSM_MMIO_OFFSET, + &quirk->mem[1], 1); + } QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); } From patchwork Sun Dec 1 16:09:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13889590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C3208D49771 for ; Sun, 1 Dec 2024 16:19:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHmeq-0006Eo-C8; Sun, 01 Dec 2024 11:18:52 -0500 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 1tHmWN-0004mv-SN for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:10:08 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHmWM-0000dY-Bi for qemu-devel@nongnu.org; Sun, 01 Dec 2024 11:10:07 -0500 Received: by mail-pf1-x441.google.com with SMTP id d2e1a72fcca58-7251abe0e69so2824633b3a.0 for ; Sun, 01 Dec 2024 08:10:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733069405; x=1733674205; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AlBD1U7cUQj71eYm0kE5fbgBocVbBBKTOkzCfY4ss1w=; b=IXT4XQIlP2MGZMKQLdCp+5Thlhvkd/rUiWnyVLGWjiFGipsiPw2nBxQwu5Z9cKD5c2 9gLtSc3psC8nHRfVdMSoHI768RYmO4ucSWosEbGuKEX/FBaE+egcqs4H9Rtt3r0wUnOl 8zvX/3Gz1Qt5OAnO3Kfa+MTw8vAWhhXXmLaTkU5mJyc9Q1vd+MHzLtyf4ShNsqlcE++Q tnSx+LZLjboGm8oDlzIg8oKVzLeOTfcv6c9LqrN5/VMzfgwb4Oa3lf91mb4qjAhMWtGk v9Xeav75emx83x/urikVXIfaca5CaZ3H0qgKLMONLE2WqgZzfZKcfX5DNEEQV8mtpR4f DSnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733069405; x=1733674205; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AlBD1U7cUQj71eYm0kE5fbgBocVbBBKTOkzCfY4ss1w=; b=IXXL4ef9mpDhizouZTqi4y3HqgmAypTvgwYe1NJw48nW4ZRBIMTtDJkh9niatUjx3a 9oeZLqMVJ6v1KPcCISAd/OyzoCYJkDG1WrfLsKHCeVb3NWt47uEa3YX+dqwsfx6++10O cy8AbTw2ygBkMuTBYImSa4Gk43h4jF5FseYkJykT6zNv3ORqBwb63tKDa3s7Z9y7uGM1 3b9JQCGSkgjK2h99mjBXECBW9zAY/y5NMymOhKQm/Y3QXdPcAq3Egieh3PI8vzQf0mNS Zf3dllmII2NlKusUpDB+s48mlfc7Cqpzq66zbxH0HaWTdjJIEpTIhAuj1PEoxpa2/YH2 NNdA== X-Gm-Message-State: AOJu0YwQIh93jHYg5Og3vBao1uHG58bd/XlMbfcU5NtS0Rfk8i1AGVCj mHZsnhvFkGrwPvwPL687x1yxPPgYxPP/UCrNFEjJXga28WWrM5d6YbGLZzj0lTa8 X-Gm-Gg: ASbGncu+1wTD6yzWti5vWkwTY0jnaCHAk6LRx3Iqy3992UbKTwitzPXzSz5X1eEmo5e 3UESN0p9e9Dq4/kIw9uMqdoSRmbIJr3rHuj55pjDwC/8WESC9vXhsg9Z160nlZ7rFpvArB+WpEJ 1kVX26hjG4Lhhkk7k3TwgaXCRxyvBp9ddvgNbxkd/5TP2/OHzMKE/+4fc56MDcXtXHpr9QneZWC 3LDxkTD/3WXfAZpBaQhV7uy4KT54WDvB/JBs5ydN63s7my/w5p0yTJjAH4= X-Google-Smtp-Source: AGHT+IGb6KG4NU8D2Ap5+OW0Lyh8BWbVFNqbq9HG7fWHXuoCwdD5t0R9yzqZachLOz1TpvjAPO0l7A== X-Received: by 2002:a05:6a00:b55:b0:71e:5950:97d2 with SMTP id d2e1a72fcca58-7253014343fmr26853070b3a.17.1733069404708; Sun, 01 Dec 2024 08:10:04 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7254176f47asm6785783b3a.43.2024.12.01.08.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 08:10:04 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH 8/8] vfio/igd: add x-igd-gms option back to set DSM region size for guest Date: Mon, 2 Dec 2024 00:09:38 +0800 Message-ID: <20241201160938.44355-9-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241201160938.44355-1-tomitamoeko@gmail.com> References: <20241201160938.44355-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=tomitamoeko@gmail.com; helo=mail-pf1-x441.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: Sun, 01 Dec 2024 11:18:43 -0500 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org DSM region is likely to store framebuffer in Windows, a small DSM region may cause display issues (e.g. half of the screen is black). By default, QEMU uses host's original value, which is determined by DVMT Pre-Allocated option in Intel FSP of host bios. Some vendors do not expose this config item to users. In such cases, x-igd-gms option can be used to manually set the data stolen memory size for guest. When DVMT Pre-Allocated option is available in host BIOS, user should set DSM region size there instead of using x-igd-gms option. Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 3fd822241d..614223123b 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -712,6 +712,23 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); + /* + * Allow user to override dsm size using x-igd-gms option, in multiples of + * 32MiB. This option should only be used when the desired size cannot be + * set from DVMT Pre-Allocated option in host BIOS. + */ + if (vdev->igd_gms) { + if (gen < 8 && vdev->igd_gms <= 0x10) { + gmch &= ~(IGD_GMCH_GEN6_GMS_MASK << IGD_GMCH_GEN6_GMS_SHIFT); + gmch |= vdev->igd_gms << IGD_GMCH_GEN6_GMS_SHIFT; + } else if (vdev->igd_gms <= 0x40) { + gmch &= ~(IGD_GMCH_GEN8_GMS_MASK << IGD_GMCH_GEN8_GMS_SHIFT); + gmch |= vdev->igd_gms << IGD_GMCH_GEN8_GMS_SHIFT; + } else { + error_report("Unsupported IGD GMS value 0x%x", vdev->igd_gms); + } + } + ggms_size = igd_gtt_memory_size(gen, gmch); gms_size = igd_stolen_memory_size(gen, gmch);