Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3976017pxb; Tue, 25 Jan 2022 00:26:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaPblXIR46tBtPjanNLHsZtDFRb3tNQC60mDIH0RAXzWmMXr0mOH/xwjU/gnko8RlHJbKU X-Received: by 2002:a17:902:9682:b0:149:15d2:55ae with SMTP id n2-20020a170902968200b0014915d255aemr18058483plp.59.1643099181151; Tue, 25 Jan 2022 00:26:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099181; cv=none; d=google.com; s=arc-20160816; b=yYmTmk8XJyX6oCRr66mWg4MDvY1mjTmB4Zi3OQzpE+Azl7DmHpVhMDykwVDb9EMJZ6 Vm0qexsfMny3Hm2wxsS56Ay5hIjr9BKcNx2cK5H7tkcaLqq62qEktyDNvXwIsSClAawS NrFLXVCTmAlhJ1IL3fV/X4wJAPVpCELHdslYbxM5I487n+ti05LtgvTWl1xOHrPOM4km Gi7colI32MayQDHFGm6pqF5VsZsjoTxmb7oIFyRg10Jc2znv7vFZmlnSgNpoZqc/G+eY PBtoZxfG/rjqssJMNOAqivJuXbgE4fIjzz8aNEljaRwUxMJrBWu+vmngESYilGaJG/T+ YXuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3oDW+L+oq9PPYeXnu0sx9E4W9XZVrBYh0Zxb0DPdRl0=; b=j2p3Us52wOtMRMsR3kz4NpfPtaLeZrH0HXzf6DvK/Qbd/WGxtvNeFwsq4dZEzNsGDU YNYSfyMlDkvsyhDW0kJOuNeGnh9tLAHlSAvXXBdYAUAl/nic/zl002/etWjEPzg27rSe c5K/C9VfL/fbyGGr9fDYqJ2vtqtNBXEzBd0LiNdktfU//OukBBF+Q7JgegSVVpUoJ1ln tuPj5Cvrsmw/XWSwOjF0K0yl1G7hOR/F7BUuDjoQXR29ZKjvKnCoeOz/W5LsA3dQwgBe iRd21UXTXRxVWdId/rK3kbnmc5VoWJunNO5L8CV+FAfWTfh+FjNVKC3YhupUS+PKjRGI Rs+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a7syHtQ8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j191si11512453pge.528.2022.01.25.00.26.09; Tue, 25 Jan 2022 00:26:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a7syHtQ8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S3422098AbiAYCaR (ORCPT + 99 others); Mon, 24 Jan 2022 21:30:17 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:52354 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379276AbiAXULH (ORCPT ); Mon, 24 Jan 2022 15:11:07 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 13F98B8121A; Mon, 24 Jan 2022 20:11:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44F98C340E5; Mon, 24 Jan 2022 20:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055058; bh=UxwUpDXJ4axt9oqEZOsHQYJIuHllOhKTqnBfWUdnq5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a7syHtQ8HGZIJXghdSU1blna47PmfoOFAcSTxeQAcoKQ6qyIfAN5Dndr63S25reEQ iDA+L/vtPKeqMqqdTl4pAS1y0bWL+SYtEaWpHY7hBGWsrI7qx4b1My9jqi8SIvNGYp xA2ni/FutLo1YFzJ6WiJzTl7cMl7B8URW/j33ruQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lucas De Marchi , Bjorn Helgaas Subject: [PATCH 5.15 027/846] x86/gpu: Reserve stolen memory for first integrated Intel GPU Date: Mon, 24 Jan 2022 19:32:24 +0100 Message-Id: <20220124184101.853015332@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lucas De Marchi commit 9c494ca4d3a535f9ca11ad6af1813983c1c6cbdd upstream. "Stolen memory" is memory set aside for use by an Intel integrated GPU. The intel_graphics_quirks() early quirk reserves this memory when it is called for a GPU that appears in the intel_early_ids[] table of integrated GPUs. Previously intel_graphics_quirks() was marked as QFLAG_APPLY_ONCE, so it was called only for the first Intel GPU found. If a discrete GPU happened to be enumerated first, intel_graphics_quirks() was called for it but not for any integrated GPU found later. Therefore, stolen memory for such an integrated GPU was never reserved. For example, this problem occurs in this Alderlake-P (integrated) + DG2 (discrete) topology where the DG2 is found first, but stolen memory is associated with the integrated GPU: - 00:01.0 Bridge `- 03:00.0 DG2 discrete GPU - 00:02.0 Integrated GPU (with stolen memory) Remove the QFLAG_APPLY_ONCE flag and call intel_graphics_quirks() for every Intel GPU. Reserve stolen memory for the first GPU that appears in intel_early_ids[]. [bhelgaas: commit log, add code comment, squash in https://lore.kernel.org/r/20220118190558.2ququ4vdfjuahicm@ldmartin-desk2] Link: https://lore.kernel.org/r/20220114002843.2083382-1-lucas.demarchi@intel.com Signed-off-by: Lucas De Marchi Signed-off-by: Bjorn Helgaas Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/early-quirks.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/arch/x86/kernel/early-quirks.c +++ b/arch/x86/kernel/early-quirks.c @@ -515,6 +515,7 @@ static const struct intel_early_ops gen1 .stolen_size = gen9_stolen_size, }; +/* Intel integrated GPUs for which we need to reserve "stolen memory" */ static const struct pci_device_id intel_early_ids[] __initconst = { INTEL_I830_IDS(&i830_early_ops), INTEL_I845G_IDS(&i845_early_ops), @@ -591,6 +592,13 @@ static void __init intel_graphics_quirks u16 device; int i; + /* + * Reserve "stolen memory" for an integrated GPU. If we've already + * found one, there's nothing to do for other (discrete) GPUs. + */ + if (resource_size(&intel_graphics_stolen_res)) + return; + device = read_pci_config_16(num, slot, func, PCI_DEVICE_ID); for (i = 0; i < ARRAY_SIZE(intel_early_ids); i++) { @@ -703,7 +711,7 @@ static struct chipset early_qrk[] __init { PCI_VENDOR_ID_INTEL, 0x3406, PCI_CLASS_BRIDGE_HOST, PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check }, { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA, PCI_ANY_ID, - QFLAG_APPLY_ONCE, intel_graphics_quirks }, + 0, intel_graphics_quirks }, /* * HPET on the current version of the Baytrail platform has accuracy * problems: it will halt in deep idle state - so we disable it.