From nobody Fri Apr 4 00:05:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1733233076; cv=none; d=zohomail.com; s=zohoarc; b=YtFW8BpL2CFvdnFfqtN9rexW1a40yfgqvup4GCHZYASZeAy1vSmwTsPYpR7M9cbuA5CMBT0vRgTUp1QBo6ltBECbRN16RMVS0iq8PLK29ePjHxTaaY8kL4v+Me7QfvKxF62P74WrNe8OLb/TSACMdC9yOBAxdZ9YVg13E+K6ryk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733233076; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3C9mQ0zqKyWU81Xua9U9FrEq7qcjZ+Cm0wPCJfJYfvI=; b=D6Js1YPydUgOzW50KlCU2NjRZ47h9dGhoae63soMUFQ7GSGcf/d0eegZe3vdp7cpnZT93hOtliwRjJNPXfkTVHD0hgsk6tgBCeJnHVvtqroyJH7QDA69Xls+Wyfqpg7y3wdmqLxBxEW1L30BUFG+lJEmI1cfqKFNBkYfP/Ti058= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733233075511662.1635124661963; Tue, 3 Dec 2024 05:37:55 -0800 (PST) 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) 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) 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) From: Tomita Moeko To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Corvin=20K=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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1733233077381116600 Content-Type: text/plain; charset="utf-8" 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=C3=B6hne --- 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) =3D=3D 0xa84) { - return 8; /* Broxton */ + /* + * Device IDs for Broxton/Apollo Lake are 0x0a84, 0x1a84, 0x1a85, 0x5a= 84 + * and 0x5a85 + */ + if ((vdev->device_id & 0xffe) =3D=3D 0xa84) { + return 9; } =20 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; } =20 @@ -258,7 +258,7 @@ static int vfio_igd_gtt_max(VFIOPCIDevice *vdev) =20 gmch =3D vfio_pci_read_config(&vdev->pdev, IGD_GMCH, sizeof(gmch)); ggms =3D (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 6) { + if (gen >=3D 8) { ggms =3D 1 << ggms; } =20 @@ -668,7 +668,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) =20 /* Determine the size of stolen memory needed for GTT */ ggms_mb =3D (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 6) { + if (gen >=3D 8) { ggms_mb =3D 1 << ggms_mb; } =20 --=20 2.45.2