From patchwork Tue Dec 3 13:35:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13892451 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 98F0CE64AA3 for ; Tue, 3 Dec 2024 13:38:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIT4Z-000810-Ki; Tue, 03 Dec 2024 08:36:15 -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 1tIT4X-00080O-Jl for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:13 -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 1tIT4W-0001Fx-6e for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:13 -0500 Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-2155312884fso38388175ad.0 for ; Tue, 03 Dec 2024 05:36:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733232970; x=1733837770; 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=9tMqvex4RuMXL27s3iBwmhMpuv9eZ7sBnrBfQ8TBDz4=; b=Q4DN9LQNJgmKZpVhNCWm43buVOTxbtNnE3Udedc5B1KEAmwOnOXI2L7/BWI7UxF1wh nCzHOOH0v7MdMXRi0vTs/hOvzdLTrwcIfU7t54ZY0JZIBggJ5OCVE6YLfkT7sXD8XSxZ svLS4loqZL30Ajad8WpePgpwk7IivB0KjCJYuMamYd8dg7Y43Z72CnVgHtGSN+E/PnbA GfY/mHMRowzfX4gpkZCHqqjhhKvCTc0N6G+uWzU6I0WAWvKBwz04U11JsmUqwTDUvOHu Z5SP85WygSSyO3/SYtPC5MlYj90jx7qkYlikDk3g8aB+6YnMI2VriyQlKwgdGGXjC8CU slBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733232970; x=1733837770; 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=9tMqvex4RuMXL27s3iBwmhMpuv9eZ7sBnrBfQ8TBDz4=; b=kSahAtEpJJx12Hos+HqPVr6U0gx3iRZIX4/TSzAo5HZOBXsxaEYTxTeKg9mZAu/Dig yxWFQUs1EAaZv0WmGfpMHouA3hRTUUnG0k+skx0jAXR5wH7oK9p2ptj80mBO+R6j+Im0 BMAK3Ams4FaGGqSNGe6XwBMePvHYfMQpgfT6vaudm5Pw4wlQeplafVOTMH97Immf7EsU snvcTYg7DBe3tIP6z/4Jn9PTibC5/EFndPJ+TLHIwkHGYe3yyz9LxxA5nKRutkILKSkB lnSS4b4mx1VQd9WC6Qu9XvxASCaVHWPf6otnUB8zf7Kl6f+3OjljUYNtXpNsqmwRzw+e ytEQ== X-Gm-Message-State: AOJu0YwBfNGY8hy2FA/47mcWQgRUsOxMMQmEW2CK8MDyDbnorQ9a1EJD 5TVROaPfhbKRMTafF8HP23fUIcB2+x+hYYQx8hgCOthULjRTwEyxBsCIS9axsA== X-Gm-Gg: ASbGncsQrrjz0sf7fkvpzYb8qdqoQMonqAx7dT5fStSIKNG7HRUZfL4csaKe0NfGQH4 2n5COVVnAiNVG33xqBjhfoUc0eppb245yfoNQLyKWeVmKam7zzLJMCq/nF+q5sXlW7IaQSKYcjm hhN0cTST/aIfXzBFhkQKSJAz298m4m77yupeuVnW2VjtV5Jg69szUzdyucTD7aoRR0Ofqz+YFgR n1dwUZv14AGbiuQ2a2kSxZKt9Gb3JT/qwbWqiP+dNF4Z6Qlual8TcgPSWs= X-Google-Smtp-Source: AGHT+IHDc+Te6C5tjWuB2vORZolpVl9YpK8G927+biuL0Pxp8OtF1D8XTK/nXryFMaFfDK8ujl3vpg== X-Received: by 2002:a17:902:dac9:b0:212:4ac2:4919 with SMTP id d9443c01a7336-215bd1c9e9dmr28972305ad.17.1733232969600; Tue, 03 Dec 2024 05:36:09 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215810cf18esm44183975ad.242.2024.12.03.05.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:36:09 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v2 1/9] vfio/igd: remove unsupported device ids Date: Tue, 3 Dec 2024 21:35:40 +0800 Message-ID: <20241203133548.38252-2-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203133548.38252-1-tomitamoeko@gmail.com> References: <20241203133548.38252-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-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. Reviewed-by: Alex Williamson Reviewed-by: Corvin Köhne Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 4047f4f071..6ba3045bf3 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 Tue Dec 3 13:35:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13892445 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 55E57E64AA6 for ; Tue, 3 Dec 2024 13:37:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIT4b-00081O-J1; Tue, 03 Dec 2024 08:36:17 -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 1tIT4Z-00081D-SS for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:15 -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 1tIT4Y-0001GD-AQ for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:15 -0500 Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-215909152c5so21624295ad.3 for ; Tue, 03 Dec 2024 05:36:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733232973; x=1733837773; 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=3C9mQ0zqKyWU81Xua9U9FrEq7qcjZ+Cm0wPCJfJYfvI=; b=iaMFG3G1iZcbsrgmz5LNdZpIkFoLOm0/5Qyhsw0zonFMHC2ZKd7aYm0EqTxzumbLMb OoeQbqdPaROqOacJ6lp9wWRWMm2VBnaz0EU132XlkiEQUyRyFCFLe4J6n69DC5QVWctE 9bwY3QYMqWbmfZ6oFmn86zuvzNex6wXwYs7+EmUidUXLJ6dQR+LqScdF3j9RHh4G7fNb H57FTSV1CQbUJhpNLrQbLvbTU65sT8YJVZQ7ceFvq1phL5EUKjlJefEYfO0xYi/XeHtl QY2Ju47WzgZLt5EVQZ4mV511VPSF1f+4eGlmODv5c6UMHXEiPddb2gk+OkByy+BCVbsj JcKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733232973; x=1733837773; 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=3C9mQ0zqKyWU81Xua9U9FrEq7qcjZ+Cm0wPCJfJYfvI=; b=HMC8vSTqnC7rzz1Oemxotu7T4ZNAyUB39qSvE223gqaRZdqZR4MSFey5sXlIpINniI s/QYTdshPpQUlVsBLdPDCJpCcBibd5tqduvm+qO2vShjsYlVjCnsNH9iky/DspmrkkGU PicnQrz0W0ZGr9g/FQ2DqdZ3bifDI6r/4fk1oJqoUj3eFPvfoxHH0k23u36/0lynao0G pLw2rB7zUoD7m0ewaC5RQO2qUc9MxiwIPv99OerWk8otoo3JELFrEqREcZmv55mJ2L2H 9Yq7AnIWBqJYE5E6D42rKY/ijRueHbvLVnrJ4Q/7dxJ3IdOKtQObJ9NCF8asU2nlK9KO WHzA== X-Gm-Message-State: AOJu0Yz8dcFBg4gIzVkPXwOsDpwPo2dOfXhEMXjbDxUrNgKdHWo9JLhx MXKxFx68EpN0mbmW4f8LzTfL5QmzCOJQbgEwb/xJ1lX3Vr1NgqMdiMu17+PGTg== X-Gm-Gg: ASbGncs6boA2pF/NAtdTlt6TmQoFWuA340r9iVZ/0a8b0XYgmVP7IqQfNf3CCWtU0pU rzSU4Y7udL/QpwZ5SNhy1MuDtEvxPrrMo3/QNqsZJQTuX7LgpdooewQ5sO1h/L/6+MaiZMjTAKg xtlZrtuWxMAZf1FMF7aF+xjwfMxaLBiEU5gI9h+o3GA3zi3h8aniqfPxqn94Jno6+jjRWykCufb XuknT+nVi2hsumWk5rwL8POUXsDRRnbDx8/KkjCqzIMDEgG2zCL3+KKYkg= X-Google-Smtp-Source: AGHT+IFzNrbbJ1dlMtfrKzVGEX6Y/ASTpr9pRVL8CXZLJU12ehycssWo+z1vGI/ZrB6H9aTGe6zL/A== X-Received: by 2002:a17:902:ea07:b0:215:75a5:f72b with SMTP id d9443c01a7336-215bd266391mr31549235ad.53.1733232972631; Tue, 03 Dec 2024 05:36:12 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215810cf18esm44183975ad.242.2024.12.03.05.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:36:12 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v2 2/9] vfio/igd: align generation with i915 kernel driver Date: Tue, 3 Dec 2024 21:35:41 +0800 Message-ID: <20241203133548.38252-3-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203133548.38252-1-tomitamoeko@gmail.com> References: <20241203133548.38252-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-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. The condition of how GTT stolen memory size is calculated is changed accordingly as GGMS is in multiple of 2 starting from gen 8. Signed-off-by: Tomita Moeko Reviewed-by: Corvin Köhne --- hw/vfio/igd.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 6ba3045bf3..2ede72d243 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -59,33 +59,33 @@ */ static int igd_gen(VFIOPCIDevice *vdev) { - if ((vdev->device_id & 0xfff) == 0xa84) { - return 8; /* Broxton */ + /* + * Device IDs for Broxton/Apollo Lake are 0x0a84, 0x1a84, 0x1a85, 0x5a84 + * and 0x5a85 + */ + if ((vdev->device_id & 0xffe) == 0xa84) { + return 9; } 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; } @@ -258,7 +258,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 >= 8) { ggms = 1 << ggms; } @@ -668,7 +668,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 >= 8) { ggms_mb = 1 << ggms_mb; } From patchwork Tue Dec 3 13:35:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13892444 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 9C82EE64A9F for ; Tue, 3 Dec 2024 13:37:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIT4h-00082K-EP; Tue, 03 Dec 2024 08:36:23 -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 1tIT4g-00082A-0q for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:22 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIT4a-0001GR-LE for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:21 -0500 Received: by mail-pl1-x642.google.com with SMTP id d9443c01a7336-215b45a40d8so10810865ad.1 for ; Tue, 03 Dec 2024 05:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733232975; x=1733837775; 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=jbedGQpZbiZzLccaIV/JwHJY9jlVFHdqI1I9GJ45Gm8=; b=Q+edaSTwIDqdoHUmXtAkF57PHUtZxPyGBm9gLyae9Ky2Y2wWF8lE8gT/6H74KvB5pf 2RhLZkfin1DJxzonCzPwqBxHPH7BzFYxf1TlRiNknvsNg+AHS8nvEsdEdPQbCf0EUiak doY5mSfar9AA5fsKdSOdCPm6xJ9c4+0ed9aP9IYoVikvtmJfN0BlLlciTO0yq+l32BiM GoM4LpYER7BsixuYHP/1MzmjLD3hYNaJRQePmudAslpDfobAp/Rm5XafuyvLHp4MptCX /9L/AvYZGVnbl4DFyLWrP2TIpdZetsLwW25z/JrH3Law+2cMyXP8jJk2P5s1PMuV2w5V XOcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733232975; x=1733837775; 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=jbedGQpZbiZzLccaIV/JwHJY9jlVFHdqI1I9GJ45Gm8=; b=cPUuZ5D6LWDhFXlACV511hzB9CmxmV98QXlCHmD+l67p902Yl4KV6cdmW5LG2iL/uV UpPJtHTzJIfaWkNKiUz2alk7DbqOJF/nBWKtHbKJXMhDcpPdV61QNAzIeg9j/UHwbZdX XnH/mCVnWM642m5qlldCiq8g1RHKndCFCXPvuJggcl3CsRzfZgacAAmekByody7xIyRt XYnhBxhq/SPebhYizoRUxBxr3U01A5ckO+FVX1MbVQxIm1eCK1WTvL9zi3aYSaynoBIr 9s5h+1x88LO1yo31cjzd1P90h1lOBafkqctmaeONlwEZmw4gYjkZRc93kYcaIBckxJFC U7UA== X-Gm-Message-State: AOJu0Ywqgm031e8JVN37YdiVz5PheBdgN7fM5SncqzkfBNDqrqpTDKVn tt8Sg5irogNEunomOHhs5mn3GgVn00skKV2utZfkZLXP3skoqx9lCMzFxyUUaA== X-Gm-Gg: ASbGncvNcPQpzIhEmMML4KG9ivBWJ6mMMjzOBmaXemFmmX67hsrD+hP9VR+NPNTkmyp rp9qo3X5yJpt5ZcIyHqxDm0AjbWhl9Q/Z/7iXTei3nxqtOZuKq0UslPnj2fPAeotofhjDld0nF2 5o5yYBzlAhMUFiCiZo3wI53w1TZJIaX3fzwQlPAz3RVuH5M8s7b2yopQV0IN8AtvMNQgJqXjm6x MK0bN2ipjX1f2tWpg1K9mvH2MXMNy8MkhgFCPV4J9O7aFbq/Ctwlj5R1fQ= X-Google-Smtp-Source: AGHT+IGPCCuc+PArskTh6njoIEoxM5kniM4GjGvmHycMHU+hoWVHnJeosKkArWVSQvx0Z6zPW7Pniw== X-Received: by 2002:a17:903:1d2:b0:215:a96d:ec2c with SMTP id d9443c01a7336-215bd0e654fmr35187245ad.28.1733232974709; Tue, 03 Dec 2024 05:36:14 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215810cf18esm44183975ad.242.2024.12.03.05.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:36:14 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v2 3/9] vfio/igd: canonicalize memory size calculations Date: Tue, 3 Dec 2024 21:35:42 +0800 Message-ID: <20241203133548.38252-4-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203133548.38252-1-tomitamoeko@gmail.com> References: <20241203133548.38252-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=tomitamoeko@gmail.com; helo=mail-pl1-x642.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-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 Reviewed-by: Corvin Köhne --- hw/vfio/igd.c | 99 ++++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 2ede72d243..b5bfdc6580 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -106,6 +106,51 @@ 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 /* SNB_GMCH in i915 */ +#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 /* BDW_GMCH in i915 */ +#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) { + return gms * 32 * MiB; + } else { + if (gms < 0xf0) { + return gms * 32 * MiB; + } else { + return (gms - 0xf0 + 1) * 4 * MiB; + } + } + + return 0; +} /* * The rather short list of registers that we copy from the host devices. @@ -254,17 +299,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 >= 8) { - 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); } /* @@ -471,30 +509,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; @@ -504,7 +518,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; @@ -666,13 +681,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 >= 8) { - 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 @@ -683,7 +693,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)); @@ -734,5 +744,6 @@ 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, + (ggms_size + gms_size) / MiB); } From patchwork Tue Dec 3 13:35:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13892450 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 03978E64AA3 for ; Tue, 3 Dec 2024 13:38:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIT4f-00081v-4Y; Tue, 03 Dec 2024 08:36:21 -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 1tIT4e-00081l-Al for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:20 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIT4c-0001Gg-S9 for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:20 -0500 Received: by mail-pf1-x442.google.com with SMTP id d2e1a72fcca58-7251ace8bc0so4567471b3a.0 for ; Tue, 03 Dec 2024 05:36:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733232977; x=1733837777; 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=ZjcHxmTcRcs6gnPDz+2J4eyjqpNf01UJzBW549ZcPYA=; b=AqMeUzp5zEZLHNn7V9T9QjWq+lSCCzawjvgvRt4L7stq4J86onJPgM8sHS5jwdIqnp 9pZZeBjEnAU+KZIm8Pi51/4motMlfGRJboTA9yyiHmtO7GfAv8IU5YfCPPKnkstIORrr WzIbqJAjMNu9ORyfCkccou7dd1lVL1uasXx83u5x0u0Q+mpd7/MY+LpvmJ5818qDVO/P 8q3poSR4Qm8JZd3iZe8opSh9dFq911JMqZtoG8WULGnsx60eMKPfCispo9VTk771J8Bb kjr6j2v6c9KUqd8WSEvmJYpa3vMToSv/n4fe1yB4UsGyWCgpiQ7BP++RH7zGXUKz9JeJ 1ong== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733232977; x=1733837777; 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=ZjcHxmTcRcs6gnPDz+2J4eyjqpNf01UJzBW549ZcPYA=; b=pTZXCjYlwsiajWn7QkKJtyyGSds4cbRV1NFeEH51BERPQ793ChF9qNXJgKgtfInSKA 3+dWpcfwBZU8xNwrHhflhLZWcHnBpcxkxboBNe3OcGSMkbZXm57nWzeprLwxhmpNk69H XHZIdW2dH5toWdP52UerY7HmO0s7aOlayaQZyALKGlVLyCXJGQbBS+MGbKMzfMwN5Uw+ 3/2NfLuO7/Yo2RByTKg6BBYXt7SlPZXNs4c5aAIRlWxJLtM/5E0yp23WVlk5NVJUoyPa HCDeGbZ3BSFIZUvhUIK8vAq/HXKu15btBnwWO7jUwJpDuyoCKB7Bx1DHw0CLL7fbFXk+ iMVw== X-Gm-Message-State: AOJu0Yx4LRT8NugX27Ga41cgIC6QvDxWfeNdFIDKxr4GDOfGysptAvVN FpHyu4zY5g6Xn24qst/cm5nFcoSsEXmmjuLGQQWDSOqjmIEjrAqa+tlQtMvHiw== X-Gm-Gg: ASbGncsoQzooYF+KvljnAOcjux9LztPV8qMZzDOUnzIrhzp3T4NTH4g10vyJ8zpQB5D e9RxTb4O7VUx/zqAsxvjXokBXdhUGIPNHEZhlbY51iO9o9I9PdorHla3siWixcdU/bCuqXTf8G3 2W4RXYdW0qviFyYMhqGYWCPOcoBx+porxyMGSqaN0eaAZf3tpPqIvvpD1xVyDyMhBSBFo9tPJMP 07vrpNwhR+VedA9YFx+eJdurcGOF0fGGSp9l583Ywl/XTB0bYqaKlV3JAg= X-Google-Smtp-Source: AGHT+IHLU8Qbd8COS32ppcZTd9Xilkw/vVDaxNE5+Jl9ZL2XC+XKBqCf2F2X2DjpP5bJvCnMut7peQ== X-Received: by 2002:a17:902:e746:b0:215:7136:f7e3 with SMTP id d9443c01a7336-2157136fb52mr209800245ad.19.1733232976853; Tue, 03 Dec 2024 05:36:16 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215810cf18esm44183975ad.242.2024.12.03.05.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:36:16 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v2 4/9] vfio/igd: add Gemini Lake and Comet Lake device ids Date: Tue, 3 Dec 2024 21:35:43 +0800 Message-ID: <20241203133548.38252-5-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203133548.38252-1-tomitamoeko@gmail.com> References: <20241203133548.38252-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=tomitamoeko@gmail.com; helo=mail-pf1-x442.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-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 Gemini Lake and Comet Lake are gen 9 devices. Many user reports on internet shows legacy mode of igd passthrough works as qemu treats them as gen 8 devices by default before e433f208973f ("vfio/igd: return an invalid generation for unknown devices"). Signed-off-by: Tomita Moeko Reviewed-by: Corvin Köhne --- hw/vfio/igd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index b5bfdc6580..7f389de7ac 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -80,8 +80,10 @@ static int igd_gen(VFIOPCIDevice *vdev) case 0x2200: /* Cherryview */ return 8; case 0x1900: /* Skylake */ + case 0x3100: /* Gemini Lake */ case 0x5900: /* Kaby Lake */ case 0x3e00: /* Coffee Lake */ + case 0x9B00: /* Comet Lake */ return 9; case 0x4500: /* Elkhart Lake */ return 11; From patchwork Tue Dec 3 13:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13892447 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 88836E64AA4 for ; Tue, 3 Dec 2024 13:38:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIT4k-00083G-7R; Tue, 03 Dec 2024 08:36:26 -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 1tIT4h-00082L-BC for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:23 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIT4f-0001Gw-88 for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:23 -0500 Received: by mail-pl1-x644.google.com with SMTP id d9443c01a7336-215bb7bb9f9so6991585ad.2 for ; Tue, 03 Dec 2024 05:36:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733232979; x=1733837779; 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=A/DuqT4YM84gPF3le/nSWMQOdJuCxA3rOOpHfejjt74=; b=T7iwGGkfaKp8RMbnWljRK6Ye3xJ3I4l41FrPc1SyDyfbAMl6Nb34ny08nmW0c4fAcj 2hBPvKdckFiH9dc5gjnrgmKQ2zLEldEPLHfTpDwyrezT71KIO0WjBBR59R1OfsLi9GID 8emkWnQe4B8YPXV1YsarKCLTsbzY1p4fIOlJxkO9tYlJngjHWw014GnGFDJWF1Rm3V/A C36DF8DrWNJaLSQFc6Y4ot49XySpX9twGYlpGperGAgEFOUf2QMOjU/78W0J5kUHpkbg C+HaUj6z/FttHzTMKSiXQ007GtQcRQfiZxdXwqD/GcmtEmpxX930bTFXes0/0EWAx/tW 9Tqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733232979; x=1733837779; 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=A/DuqT4YM84gPF3le/nSWMQOdJuCxA3rOOpHfejjt74=; b=c+28+A5CJtR5+jlejw2z2lF36YODtJWJNKesG7kGdREBxCRadGY+x/iOdxcK7kV7N8 +Vlvtjzrd05mN/CyQcoigqBO8KBSIST4neCmWx/gEM+gp5rmHzAZEwbUkDlPzyshO6f6 YuAZzor7TC7B6hrTpW64Nk0SzfQKMF+qDdapx3vIKgHqhfxBoo6x/scn8wG9i+aJWXZh +3NLlRUZAHFjQ/hiycegTWGMybixhVYreqevQ7RQOCwrS3ogEkYeJpIHp1zHegy9BFgj RC/oeyteuHWLYOs3pjDDuX6tKfVoq6WhnZtA6C75i685I68pG2MVtmr3lUAPdfypRe9b qHXg== X-Gm-Message-State: AOJu0YztJYLwYyC0qz9pBXXaxJZORdUef3yjESq/UP/uqwuwwwHgu7fe xbRWUrEOkzlKoTTvIJxymwoCuAXKp3xR30LZCokKvoEEOYK1itrKhNhgR5wAzQ== X-Gm-Gg: ASbGncvuaPocsJ+ZcW5Upf4zwB+h/WhCmgfOIH/MzPrxZYuFIRs9paa1Y700T9JPOx5 yplsEZ43ZIvrQ7/XRVSUIOrRcjn/T+yLP6HLjJr/yx7xaUzGKBVjxDTAa4CvGtXD3Mcavd/EzvE Rp9sXToxChnKgW5AHoo4lC8o0PxVS/qqwZ4rBCLj46gle+Fg9w0lNveMtQYLxx18tlumxbyLyRp HGLT0r+F6lenVRhwPGZIQoSwIevZ6lO5H7DqVthvlL3G9Gk8ZoEYSbwMwg= X-Google-Smtp-Source: AGHT+IGVFDaR012smf+bYJoWYBrsYjqrK1kIrAILHozHubIBXgZxpKPvnizC925vCzknUEKsT+0Brg== X-Received: by 2002:a17:903:22c5:b0:215:6e28:8249 with SMTP id d9443c01a7336-215d00b96bamr2375185ad.45.1733232978933; Tue, 03 Dec 2024 05:36:18 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215810cf18esm44183975ad.242.2024.12.03.05.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:36:18 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v2 5/9] vfio/igd: add Alder/Raptor/Rocket/Ice/Jasper Lake device ids Date: Tue, 3 Dec 2024 21:35:44 +0800 Message-ID: <20241203133548.38252-6-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203133548.38252-1-tomitamoeko@gmail.com> References: <20241203133548.38252-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=tomitamoeko@gmail.com; helo=mail-pl1-x644.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-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 7f389de7ac..fea9be0b2d 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -85,9 +85,14 @@ static int igd_gen(VFIOPCIDevice *vdev) case 0x3e00: /* Coffee Lake */ case 0x9B00: /* Comet 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 Tue Dec 3 13:35:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13892448 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 50422E64AA4 for ; Tue, 3 Dec 2024 13:38:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIT4k-00083a-RH; Tue, 03 Dec 2024 08:36:27 -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 1tIT4i-00082i-CY for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:24 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIT4g-0001H8-Jj for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:24 -0500 Received: by mail-pl1-x644.google.com with SMTP id d9443c01a7336-215a0390925so20946135ad.0 for ; Tue, 03 Dec 2024 05:36:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733232981; x=1733837781; 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=xpWNENhtDze8yzSa9nxZOuFXOnFwLl1CdxHyDNuyQqk=; b=coYLm85U/xjTULTqMu96IXt4S+UV00DzLfaDIf3FmJ7mlA2nj9xsawLeE4OxSv/5cw xr2a5i62m9eANC3fneuIx7r7mQGgruyE1DO7Du5rJJN2h4T3jJjr9y+Pywq+1MIRhiLu tSmJfWtG3g9s/Cvco//sv3p5edBIHpoMZ4ajd2ewsY1M2AVE7HPk6YBB5Cg9Iwzq/b/7 33v8zYJL5sW5YpH4fSjqr4nP0/tImxSmOPPgsPhS5f5k7dC0cAQYzg2zZEnF5EAqyWVb GpD7KOtCWHvR1w07xndnp3TQR2pmConYtWljQPPWb6O6ZADwIoIeZnNs6Q/JPRrB3VBz Q89Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733232981; x=1733837781; 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=xpWNENhtDze8yzSa9nxZOuFXOnFwLl1CdxHyDNuyQqk=; b=tws9FPJFqgPbZBn59BYKjH1upos5tBFEvf9kM7p+uFv3O8UgrXlduwYo/AHP3BdIfc 3Hy9d2qh9j9KB9YGwzUIkDK0jw9jg0HhMZBgFMX3zDTsWi4T2eCaS/h698MCZWBQb1sv J9T5zYxLy9HxMbTPWe65FL8px6LPL8woqpriaY1d6jlB1tzl5hrZNlI7NOsuzB1bwhiT hgTnLsYQdB/BmQAt3ud3q7R8dJj65mWK3O0bLuEN5QJCPSM+GFGcQhPiRGTdtEBz5mTw ekw0PR0MVp1pNBHRXUJ4K89H6pDdLcszEu0w/bKjYRToPnst2iPGTiV4i7aEV8s3mfoU C7SA== X-Gm-Message-State: AOJu0Yy+yzh036STypqZBNAvttI7GS0T/+Lv+RvMzDAA2NEE8O+NUBbw HCB2hP32WrJMpxD2rGyErHzI5ewIWzvQzB7//nqjIb2fDA4Vs+7Zn5YHBwiJlQ== X-Gm-Gg: ASbGnctOjVAFl6MzHHRqKj+veTqUh1QUdQwoy9bBgqdatoQ4QGSucTspAFoVTQzXbYp fYH2nGU6/QSx36fVEdvRW1Ad1elfpdoEMHc0AIyDP1hiEDL3KFJGXWxRQDuAG80su3ZPsUUdLRa eo+3OWRdLCE4nRIqbobtmVKkerKjNSnZDmKEyW/MY8gs4jDRZ/55EbRq0guYvWMtLshXjdM7imC ROCv3jcJxWGxsnex883RpVcKnJ8tWlL4g2eFVzevsITlslEgZ9CiUzczvw= X-Google-Smtp-Source: AGHT+IGaUn0Zy2qbg9V4/N1nPp/lD3k/R44Ub7Bk+cBjKBElGANJisWInDwWItjS1Tm3jvdtqfO2SA== X-Received: by 2002:a17:903:1c1:b0:215:6e28:8260 with SMTP id d9443c01a7336-215bd266031mr24705765ad.50.1733232981039; Tue, 03 Dec 2024 05:36:21 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215810cf18esm44183975ad.242.2024.12.03.05.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:36:20 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v2 6/9] vfio/igd: add macro for declaring mirrored registers Date: Tue, 3 Dec 2024 21:35:45 +0800 Message-ID: <20241203133548.38252-7-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203133548.38252-1-tomitamoeko@gmail.com> References: <20241203133548.38252-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=tomitamoeko@gmail.com; helo=mail-pl1-x644.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-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 igd devices have multipe registers mirroring mmio address and pci config space, more than a single BDSM register. To support this, the read/write functions are made common and a macro is defined to simplify the declaration of MemoryRegionOps. Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 60 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index fea9be0b2d..522845c509 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -418,16 +418,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); @@ -438,21 +431,17 @@ static uint64_t vfio_igd_quirk_bdsm_read(void *opaque, case 8: return pci_get_quad(vdev->pdev.config + offset); default: - hw_error("igd: unsupported read size, %u bytes", size); + hw_error("igd: unsupported pci config read at %lx, size %u", + offset, size); break; } return 0; } -static void vfio_igd_quirk_bdsm_write(void *opaque, hwaddr addr, - uint64_t data, unsigned size) +static void vfio_igd_pci_config_write(VFIOPCIDevice *vdev, uint64_t offset, + uint64_t data, unsigned size) { - VFIOPCIDevice *vdev = opaque; - uint64_t offset; - - offset = IGD_BDSM_GEN11 + addr; - switch (size) { case 1: pci_set_byte(vdev->pdev.config + offset, data); @@ -467,17 +456,37 @@ 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 pci config write at %lx, size %u", + offset, 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_BDSM_GEN11, bdsm) + +#define IGD_BDSM_MMIO_OFFSET 0x1080C0 + void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) { VFIOQuirk *quirk; @@ -507,10 +516,11 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) quirk = vfio_quirk_alloc(1); 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[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 Tue Dec 3 13:35:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13892446 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 63614E64A9E for ; Tue, 3 Dec 2024 13:38:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIT4m-000842-SM; Tue, 03 Dec 2024 08:36:28 -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 1tIT4k-00083T-HY for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:26 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIT4i-0001HS-RZ for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:26 -0500 Received: by mail-pl1-x644.google.com with SMTP id d9443c01a7336-215b9a754fbso8803955ad.1 for ; Tue, 03 Dec 2024 05:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733232983; x=1733837783; 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=WqEk4QSdK+ADWOaMOo65vdWqo7DUiTKvO758XSd7V+E=; b=KDE0RaR//01gKbsg6khpDeXfxT0keJWMuRcnmfp9O2sMr9llWLSL6e5k6t/wGsTFsQ /QheXcQ6sx720UhMLMiMIzx1tKXU46/xXtmF0FCI6MzFAvrz2sDzAU6keWMrgC1qQEtH xaVfamN7f60r9ovPQ2vNuoaZp9FFMzdY3bYxqb0k3P4psNcwTMpsuaslxLLjnvSqdL++ 8Kgopdx7F8KgkBxASrVSMzpCJGohOr/o0FIFHVKJeRWg2KWBinDPWScCuOTkGt6iYliC cVGMdGhjioOJj85wXiWdUuwCfVhblKF8c66mUcbpi2pwvtAhedM2rLP3CwxBHZhDa31o mo5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733232983; x=1733837783; 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=WqEk4QSdK+ADWOaMOo65vdWqo7DUiTKvO758XSd7V+E=; b=INgNKbF7NX6tNDYYk3lFeDbN5lSmS3jCfShhY4u5BSCWANxLxR3LLw13eckI3HxMIf Yqyxlnn4QcjqkABbmqjCgbiIgVgwBkHxE64Tnyk3MQtZt5cqRtlwfZS2vEKdykPcIhVe NdzYANZul3L0c29EfO0L2fAidwKd60PW8gugPEuKlPVpB9EYor1COdRyaeNVu7Yj724x av9m1KlsgDwo658hKBrv0W59oNV+l426ImtABpnNOCi2ikLBYqSzBgdwYZKjjrX/kKms FRuUnYA1yYjVi6sz9Ddg5CgQZnkNTrztkrOob7u4dfR1CKIcSw/C6RXtjtLeGoaXbesD PURg== X-Gm-Message-State: AOJu0YycySl0ONAW9fcCsb9NtMGHHbamNLT7lOneteoQoyFYyZaUcET0 TKwf81Z9X0AmXq1K1wamLG/8Zfa8qUiQE/YcVxuqxxOoQDgR8UhUqlDnivrLJA== X-Gm-Gg: ASbGncuUCy2GKWJ0uBLvNus5JvHGNaZcy3dh6FaDfCsD9GNERAoE3Xsol+GcuNfQbxa n9yx9nkXxCrxGDxnd8dVTVTx/fx29hKjRSwz3VrGM7xKe1846sVjhciea4rL7DipTZYFn+jdXY8 86yhEAEb083Qef+GZv5DgyZM4B5yqXqFNmyIa7SMLupQ2SFv3TW+Fxw8BgxGbKT71ENr6mTDjdr RxC6AsSGSwD1uGfM97d1Au4s+WfsWzrvdLcwX8KHn3J/OourfaSxwzuNxc= X-Google-Smtp-Source: AGHT+IEYiVCkVYMPqwfp7JdomS9h8enpXN2aA2H25ejNtXt45LIjaAtdgRI1ctC8tkv1eX1vTKeBZQ== X-Received: by 2002:a17:903:32cc:b0:215:6e07:e0c9 with SMTP id d9443c01a7336-215bd25580bmr32592225ad.53.1733232983215; Tue, 03 Dec 2024 05:36:23 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215810cf18esm44183975ad.242.2024.12.03.05.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:36:22 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v2 7/9] vfio/igd: emulate GGC register in mmio bar0 Date: Tue, 3 Dec 2024 21:35:46 +0800 Message-ID: <20241203133548.38252-8-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203133548.38252-1-tomitamoeko@gmail.com> References: <20241203133548.38252-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=tomitamoeko@gmail.com; helo=mail-pl1-x644.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-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. [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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 522845c509..bc18fc8cc0 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -483,8 +483,10 @@ static const MemoryRegionOps vfio_igd_quirk_mirror_##name = { \ .endianness = DEVICE_LITTLE_ENDIAN, \ }; +VFIO_IGD_QUIRK_MIRROR_REG(IGD_GMCH, ggc) VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM_GEN11, bdsm) +#define IGD_GGC_MMIO_OFFSET 0x108040 #define IGD_BDSM_MMIO_OFFSET 0x1080C0 void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) @@ -513,9 +515,16 @@ 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_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); From patchwork Tue Dec 3 13:35:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13892442 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 42216E64A94 for ; Tue, 3 Dec 2024 13:37:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIT4o-00084E-JY; Tue, 03 Dec 2024 08:36:30 -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 1tIT4m-00083r-H8 for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:28 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIT4k-0001He-Ts for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:28 -0500 Received: by mail-pl1-x642.google.com with SMTP id d9443c01a7336-215b9a754fbso8804725ad.1 for ; Tue, 03 Dec 2024 05:36:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733232985; x=1733837785; 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=C6y3oESVfrKOXA+XnLfa+UeX0xbcIB3f2chF6SF2TD4=; b=gQUUbNgN+GagQ19IHTPH7hnPk5792PfOSLFKxNyqYTbuLS1FCvQ+gDBjrRgIxYueaY V1N8JyZ2HgahngABXIWBuSHsm/fiAro93vXEv1cBiJtmc4mMEmJHstz4EOn1fXwCVkow n4eLWrD+YkyGF+EGxsrkmE1s2lTVxyQJ+2CTNWFTjEy6/De+3Fj5PQajr+SukNiBSYFY abmv+xVVXHbHHgrBjw+QGBJUigvyvX+U5LusUblxY0nAWvEAdcmyjb6GoZzVotZ5IGyY ZCsY5dQvWwL6pANjY9d0V56oVbRrtr2BVYySADH5IO62KrGlJa48iM0MuDUXK2CmMn27 OshA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733232985; x=1733837785; 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=C6y3oESVfrKOXA+XnLfa+UeX0xbcIB3f2chF6SF2TD4=; b=UjvW+xdbUXTPISPG86rWUCX2H0bxWABhUk1zNZCSqy+OcDi7O7s/xumxMz39vZgcH3 gkhdn0xTd3/S+OMmTHiVWjhHscChuwjpCfyFh6TYX3cQWRySK8jT4dg62vAS7gX4gjW0 LJUpMi7WKic+UGDQHmNqXZ8+TGJP+Ry5U4cIoK7/CCQ/ap+uVc+qj+twtNrSwkpfMns0 t5ph3eSGnbqJwQtywTmpo2STNI3hK5jFloXjiCrLBKSblOdgoNYlMvzafs/0Xwbnxdwg s1nmXPMexobPxJneCxMctb2xIADnGaO1+QNXboVGz1Bg/LaEP9pICDZ0FP574TdvNHQ0 EOkQ== X-Gm-Message-State: AOJu0YyZZ308vxqxCJd0VR0eoqlcN1FrkFMHM6c5K8B1A1zYEOqwuMsC Z3l5NrHqV1CuFaSp0DrWsKmgWA/s5hlNnZQyAZmFBcBv52vbdaf/gPrjupMUwA== X-Gm-Gg: ASbGnctWZ2HKYEfJ2xeBFtzWgaISHKQEBGOSQKEfBupgS0JyEEUi3vtaCpJthmzKW+I 0o+GtNRomS+rOVstCP6cem3Ygxsde6yhBSOFWN9SqHLSJ71S9b5OoLqPWVb31IN5C8zH5lXf3ZK EPM9pGlS96KTNr1Xg916f7CH77MOw6/46scJsa5zSZk693KTZ/3fDFJHGkojYgC60Mliua901aw xMohEtd8NoSYtH5xUlrdIdxPgDKOC2YyW3JrBkEm8C0yp3JjXgwyBu1TYc= X-Google-Smtp-Source: AGHT+IGbTN/CU/lv2UfQcCfeoRpd3uBTpSmG+s4O317DJI/1IOZMDonFrSmrsnMxZb6+HzzSHBlT4A== X-Received: by 2002:a17:903:8c5:b0:215:6995:1ef3 with SMTP id d9443c01a7336-215bd1b459emr24735095ad.3.1733232985279; Tue, 03 Dec 2024 05:36:25 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215810cf18esm44183975ad.242.2024.12.03.05.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:36:24 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v2 8/9] vfio/igd: emulate BDSM in mmio bar0 for gen 6-10 devices Date: Tue, 3 Dec 2024 21:35:47 +0800 Message-ID: <20241203133548.38252-9-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203133548.38252-1-tomitamoeko@gmail.com> References: <20241203133548.38252-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=tomitamoeko@gmail.com; helo=mail-pl1-x642.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-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 Reviewed-by: Corvin Köhne --- 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 bc18fc8cc0..e464cd6949 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -484,7 +484,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) #define IGD_GGC_MMIO_OFFSET 0x108040 #define IGD_BDSM_MMIO_OFFSET 0x1080C0 @@ -511,7 +512,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; } @@ -525,12 +526,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 Tue Dec 3 13:35:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13892449 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 3F5CCE64A9E for ; Tue, 3 Dec 2024 13:38:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIT4p-00084O-5G; Tue, 03 Dec 2024 08:36:31 -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 1tIT4o-00084F-JD for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:30 -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 1tIT4n-0001Hr-3A for qemu-devel@nongnu.org; Tue, 03 Dec 2024 08:36:30 -0500 Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-2155e9dcbe7so28738355ad.3 for ; Tue, 03 Dec 2024 05:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733232987; x=1733837787; 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=zjHE9Z6WrftEnGOF6FxD/A7yotkBFL8L2UOLnZiXDUY=; b=VEc2cEix2Audq4OasIxx752ns1jAAJJTXqzoessUZuQ9lZ2lro5SCT9bjMeGj3Ljf/ BJHoAG+2+2G1JnBDAdbTXruMnKRZm9CkOreTz1lhvS9YZAqJylFvmwgvrDLPjDcGTnzk WgReT3LIwZM3TCLu+/IC+pcIGVbiCdAetpQq+kTIW/S8rDfi7EwW2Y016q8pfnqjnyvk 8gVSvvXmtJVYoJNLS2iwjl2/SUxo8ZR5fvdy/tns0YbjWo768QICDsvQUctXYen5VhZK CUitMVoG+XGhKNPFmb4RTfjhGsw3oQ6X4NEvK7vBmJk+X26MgOCCrUZc0cQA3bho64US nKlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733232987; x=1733837787; 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=zjHE9Z6WrftEnGOF6FxD/A7yotkBFL8L2UOLnZiXDUY=; b=JQsNbT2Csn43kRfBKq3O5P4AB+iAR7DewaxFRDACk9Dc9h23X3xn21lYO/Z7DO5uPB 4h2kcyj8K1yaj2gMNw89anyjqroUs8P2yT1B4HIuqcZd3djlP12YNt9xBGLbr0mOhPqW jbx3YUNmNcBEaO0wKUywmDQHnBwh19U6gFWYoXxUJ4FueNNlpONckY75ZGK2eeEr8VVJ fV7tvtfiXz75lsM88xvM0NuvESLNhTsIW1zj+v6VbzYWqHPtrIhXmiEj56aEJuiBRyhQ GzYQI48mYgtY2b31NerLVC1ZFxh5Ujd/9aRQOjkZ5Sq9yBk3p/HASckDei6XgLDEHdlP dg6A== X-Gm-Message-State: AOJu0Yw4qGCxuKraJo6i4DT30L6rGrBjJe00v9o8V9Ji1MQan6C1I2hI fnXNSaqba2lChW7fZ6iNc52B9mp2wLLijFIBgxwhHA9rKGxIBokQvlLRR9h89Q== X-Gm-Gg: ASbGncvTijfR7pnGpxVPK96HgVO4rH5chF/T9tYNGzI+fhhOEJZTPf9FXLiCmV3Sg8m fFLDQa7v72ezIjrByMc1ntMTXbLykBZ6eCwzonD9bDm0rH9dD3a+Dm/NQIo4qKJogsBCfVKAeFF XUetmKWBqFxshShVZSe4GwoXGcw4Pa3s+yMk3ukujz/2io6xlHxhnVfMsLMrQWZPaei5eod2GL6 BuN6wLGLMq40tzGF/nu5GzlR3pbgVqK30tZ78/M+EfZhGTKWCj5g5RO4AM= X-Google-Smtp-Source: AGHT+IHWUvlPD2yCX4OhbnW4Zl6SiTnJvNkMWvHlS06dmulqoOAlIEL/sIvG5L8mfGH+9kQ26rfTsQ== X-Received: by 2002:a17:902:ecca:b0:215:4665:f7e5 with SMTP id d9443c01a7336-215bd16f93dmr29216905ad.43.1733232987439; Tue, 03 Dec 2024 05:36:27 -0800 (PST) Received: from kotori-desktop.lan ([116.231.112.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215810cf18esm44183975ad.242.2024.12.03.05.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:36:27 -0800 (PST) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v2 9/9] vfio/igd: add x-igd-gms option back to set DSM region size for guest Date: Tue, 3 Dec 2024 21:35:48 +0800 Message-ID: <20241203133548.38252-10-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203133548.38252-1-tomitamoeko@gmail.com> References: <20241203133548.38252-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-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 e464cd6949..0814730f40 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -717,6 +717,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);