From nobody Thu Apr 3 05:42:54 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=1733488188; cv=none; d=zohomail.com; s=zohoarc; b=Fy9FlULXcMspkAAHfrhPx9VRV4ImIfeQDvdI9W2G5XrDKoWXXu895umiqpx/Xpor5H52w8DYo0kZ2tThNg5YRdBbSjNIo0nI89DJDK5hi/FTKfuw+LrdaheIAiBVIxa6X3k44273xoltAdAPVFmRFUf3QOFM8N1jY5xdaowVPp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733488188; h=Content-Type: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=yCr1Si5UmdcLC4IV56KLZI508jQrygzNhxY3gT6chl4=; b=Qv/+ZjI28ISU2olNd8QHUhVxZePUQF87S+IEvsTdqrOPViRn1gytYZvHsbucdPWi90TlUqASuo6jh6p+AyqtG6waEOdcNpWMwnTTRruDHxbNwu8skGGj0Dbx6d1CnFLYaq/d0dGNk7iZuR019DWfw2I5vMAGe7d41etuH1/dMsw= 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 173348818873430.08364803036568; Fri, 6 Dec 2024 04:29:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXRM-0005x0-DT; Fri, 06 Dec 2024 07:28:13 -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 1tJXRF-0005wZ-QX for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:07 -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 1tJXRE-00041Y-38 for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:05 -0500 Received: by mail-pg1-x542.google.com with SMTP id 41be03b00d2f7-7fd23d9160dso930705a12.2 for ; Fri, 06 Dec 2024 04:28:03 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488083; x=1734092883; 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=yCr1Si5UmdcLC4IV56KLZI508jQrygzNhxY3gT6chl4=; b=mFXTnM3/MwT1HzpLG45V1C/ta/b6UGDKoBqqSEya11Owl7dfr42HEeB6wIQgFDJqEu KEtONb+VqlDwwIm4/K4fcEZ6A//hwKzqEI+wr8dwNKIvZmZBRJYefnVd9crzSY/C2S5t lDcuMxnsOryZqJF3jsAtlX5Mg9lWKEsxoEwTEsBpNYxq2QtuoBJqT5L+ThOmW7kDJI1r VSpva2zun6I/fcZSoFk4WJVv1Fk574un3hF9OMfyk12IZC/qa4/lMOG/Mha+ph0D8Y3v m15RMZZnOuJPgpZjQcPCqrVuQS59kEwum7ziAaFdUZVOK4EGKcSQ9a6NhZqQQIQc8LT7 aUYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488083; x=1734092883; 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=yCr1Si5UmdcLC4IV56KLZI508jQrygzNhxY3gT6chl4=; b=SQ3uNieA+2dTIW7DggA26fsxiXhFOAKkZ9jaMRgx0XzyOAwCGUsSoiH/xaSxM4Ea23 JXoo0DwiUnnmwKiTlDw2F3RJgPDuqoYP/DVbxO0XpHBi7nNCDRXu2FY1vNT61B3HWZzU JfGSOXIAw/D0zqfwtXPaUzObTMKBZIRlYCogcW4D1T2E5HNzjL2w6ZaXYbVMXEtR0TGY JTWIyL9eFZ1WaA4t7RjCddeOoLEJ/Ua54F6RPPRlo/RCnEUhZbLcTofPMRAURV1W8PEI Gn98tEsr1rUR93aoembPi5ViLaruUw/q07OEcX5A0d45Yus+HyWualH4GJ/mQmcUPend K4Pw== X-Gm-Message-State: AOJu0YwqgWZ3iRy/Ux+UdTkF+kO2nDYgj3IPq4DNI4kRrGlKMlg+97Iq KIABqKGu8Z+OJvMP2qDfwXKXh4v23xOPA19DrHLK7biohdlEIG0= X-Gm-Gg: ASbGnctfpFsZd6Mghjx8hemoNQNyTCuo8BuKr1CLV+Xfdr0OYlFDFK6RlQBfi4xAlBV agOjLfoAGv0eV5B108pvdee16hJ+7CjRUtZoh3zUdLs8uKEAPI8EeBt3MU+/ni8gzaB9q+6w2HE /LVTwHqQPacheOBP5e22kmciPOps0xdSEHzZGDPruwL4vXauf8QifDzz+mjibssbd4yiy6b4HuT 8DOPXqFlqeLr8cwoKxKv9s0HfzdmW/TbccOAVwqS/B4qfkOG12IJ2w8nA== X-Google-Smtp-Source: AGHT+IGZ/H8CQLg0JG+d4G+cGZgkcqsDPjr7UG3EqVLXEihxm4XSJquwabTpAOYvJIQ30SVdp/GkkQ== X-Received: by 2002:a05:6a21:99a2:b0:1e0:de01:4407 with SMTP id adf61e73a8af0-1e18713703cmr5172849637.37.1733488082773; Fri, 06 Dec 2024 04:28:02 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Cc: qemu-devel@nongnu.org, =?UTF-8?q?Corvin=20K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 03/10] vfio/igd: align generation with i915 kernel driver Date: Fri, 6 Dec 2024 20:27:41 +0800 Message-ID: <20241206122749.9893-4-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::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-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: 1733488190898116600 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. Reviewed-by: Corvin K=C3=B6hne Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 059ed56439..09bd4e5383 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -59,33 +59,34 @@ */ 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, match bit 11:1 here + * Prefix 0x0a is taken by Haswell, this rule should be matched first. + */ + 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 +259,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 && ggms !=3D 0) { + if (gen >=3D 8 && ggms !=3D 0) { ggms =3D 1 << ggms; } =20 @@ -668,7 +669,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 && ggms_mb !=3D 0) { + if (gen >=3D 8 && ggms_mb !=3D 0) { ggms_mb =3D 1 << ggms_mb; } =20 --=20 2.45.2