From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF0D4C433F5 for ; Mon, 10 Jan 2022 17:32:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238004AbiAJRcO (ORCPT ); Mon, 10 Jan 2022 12:32:14 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:41270 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237928AbiAJRcN (ORCPT ); Mon, 10 Jan 2022 12:32:13 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 3AA7C6133A for ; Mon, 10 Jan 2022 17:32:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54305C36AE3; Mon, 10 Jan 2022 17:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641835932; bh=t98gqD7BIMhMBvOpKYCXh7N7q0jeHfw2jEg5f/9u0Kg=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=a7/y64Th+145iNHeRtBrtwEHdwV+1540t3LreDP5Vr/PpDgd0fCUV1VfJHirX0WR5 5IGc6cSMb8bkoEWAGK/8xVSF27nkLn7e0z8qY/5AUBX1yhWc7e9BKznE6I8/uXTIX6 dcLZAMVaIiFoFtyXFtOHXtSoh12k94rRCyt5Gp5nZ2gGHLyFEXnRkp7KGbl+jhROOy DSc2IVwrae2WD0k37cSd1EYC7ixjWs9W3Tb+M5PN9vF3enugj+gn4JmaqEyoMwa9lk OZLSDsRDWBSEuvt6xZSlYJw27T78xz8wvGvV8Ig0NMDN4D0KN7GUoGitYFX4qNVh5R iR9SzkR7Conkg== Date: Mon, 10 Jan 2022 11:32:11 -0600 From: Bjorn Helgaas To: Rodrigo Vivi Cc: Lucas De Marchi , Dave Hansen , linux-pci@vger.kernel.org, intel-gfx@lists.freedesktop.org, x86@kernel.org, Ingo Molnar , Bjorn Helgaas , Thomas Gleixner Subject: Re: [Intel-gfx] [PATCH v3 3/3] x86/quirks: Fix stolen detection with integrated + discrete GPU Message-ID: <20220110173211.GA61717@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Mon, Jan 10, 2022 at 12:11:36PM -0500, Rodrigo Vivi wrote: > On Fri, Jan 07, 2022 at 08:57:32PM -0600, Bjorn Helgaas wrote: > > On Fri, Jan 07, 2022 at 01:05:16PM -0800, Lucas De Marchi wrote: > > > early_pci_scan_bus() does a depth-first traversal, possibly calling > > > the quirk functions for each device based on vendor, device and class > > > from early_qrk table. intel_graphics_quirks() however uses PCI_ANY_ID > > > and does additional filtering in the quirk. > > > > > > If there is an Intel integrated + discrete GPU the quirk may be called > > > first for the discrete GPU based on the PCI topology. Then we will fail > > > to reserve the system stolen memory for the integrated GPU, because we > > > will already have marked the quirk as "applied". > > > > > > This was reproduced in a setup with Alderlake-P (integrated) + DG2 > > > (discrete), with the following PCI topology: > > > > > > - 00:01.0 Bridge > > > `- 03:00.0 DG2 > > > - 00:02.0 Integrated GPU > > > > > > Move the setting of quirk_applied in intel_graphics_quirks() so it's > > > mark as applied only when we find the integrated GPU based on the > > > intel_early_ids table. > > > > > > Signed-off-by: Lucas De Marchi > > > > I don't know the details of stolen memory, but the implementation of > > this quirk looks good to me. Very nice that it's now very clear > > exactly what the change is. > > > Reviewed-by: Rodrigo Vivi > > Bjorn, ack to merge through drm-intel? This is a bit of a shared area between the x86 folks and me, but certainly no objection from me. Acked-by: Bjorn Helgaas > > > --- > > > > > > v3: now that we do the refactor before the fix, we can do a single line > > > change to fix intel_graphics_quirks(). Also, we don't change > > > intel_graphics_stolen() anymore as we did in v2: we don't have to check > > > other devices anymore if there was a previous match causing > > > intel_graphics_stolen() to be called (there can only be one integrated > > > GPU reserving the stolen memory). > > > > > > arch/x86/kernel/early-quirks.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c > > > index df34963e23bf..932f9087c324 100644 > > > --- a/arch/x86/kernel/early-quirks.c > > > +++ b/arch/x86/kernel/early-quirks.c > > > @@ -609,8 +609,6 @@ static void __init intel_graphics_quirks(int num, int slot, int func) > > > if (quirk_applied) > > > return; > > > > > > - quirk_applied = true; > > > - > > > device = read_pci_config_16(num, slot, func, PCI_DEVICE_ID); > > > > > > for (i = 0; i < ARRAY_SIZE(intel_early_ids); i++) { > > > @@ -623,6 +621,8 @@ static void __init intel_graphics_quirks(int num, int slot, int func) > > > > > > intel_graphics_stolen(num, slot, func, early_ops); > > > > > > + quirk_applied = true; > > > + > > > return; > > > } > > > } > > > -- > > > 2.34.1 > > > From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 B5FAEC433EF for ; Mon, 10 Jan 2022 17:32:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F1E01121A3; Mon, 10 Jan 2022 17:32:15 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id E38641121A3 for ; Mon, 10 Jan 2022 17:32:13 +0000 (UTC) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 301216133C; Mon, 10 Jan 2022 17:32:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54305C36AE3; Mon, 10 Jan 2022 17:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641835932; bh=t98gqD7BIMhMBvOpKYCXh7N7q0jeHfw2jEg5f/9u0Kg=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=a7/y64Th+145iNHeRtBrtwEHdwV+1540t3LreDP5Vr/PpDgd0fCUV1VfJHirX0WR5 5IGc6cSMb8bkoEWAGK/8xVSF27nkLn7e0z8qY/5AUBX1yhWc7e9BKznE6I8/uXTIX6 dcLZAMVaIiFoFtyXFtOHXtSoh12k94rRCyt5Gp5nZ2gGHLyFEXnRkp7KGbl+jhROOy DSc2IVwrae2WD0k37cSd1EYC7ixjWs9W3Tb+M5PN9vF3enugj+gn4JmaqEyoMwa9lk OZLSDsRDWBSEuvt6xZSlYJw27T78xz8wvGvV8Ig0NMDN4D0KN7GUoGitYFX4qNVh5R iR9SzkR7Conkg== Date: Mon, 10 Jan 2022 11:32:11 -0600 From: Bjorn Helgaas To: Rodrigo Vivi Message-ID: <20220110173211.GA61717@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Intel-gfx] [PATCH v3 3/3] x86/quirks: Fix stolen detection with integrated + discrete GPU X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: x86@kernel.org, linux-pci@vger.kernel.org, intel-gfx@lists.freedesktop.org, Dave Hansen , Lucas De Marchi , Ingo Molnar , Bjorn Helgaas , Thomas Gleixner Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Mon, Jan 10, 2022 at 12:11:36PM -0500, Rodrigo Vivi wrote: > On Fri, Jan 07, 2022 at 08:57:32PM -0600, Bjorn Helgaas wrote: > > On Fri, Jan 07, 2022 at 01:05:16PM -0800, Lucas De Marchi wrote: > > > early_pci_scan_bus() does a depth-first traversal, possibly calling > > > the quirk functions for each device based on vendor, device and class > > > from early_qrk table. intel_graphics_quirks() however uses PCI_ANY_ID > > > and does additional filtering in the quirk. > > > > > > If there is an Intel integrated + discrete GPU the quirk may be called > > > first for the discrete GPU based on the PCI topology. Then we will fail > > > to reserve the system stolen memory for the integrated GPU, because we > > > will already have marked the quirk as "applied". > > > > > > This was reproduced in a setup with Alderlake-P (integrated) + DG2 > > > (discrete), with the following PCI topology: > > > > > > - 00:01.0 Bridge > > > `- 03:00.0 DG2 > > > - 00:02.0 Integrated GPU > > > > > > Move the setting of quirk_applied in intel_graphics_quirks() so it's > > > mark as applied only when we find the integrated GPU based on the > > > intel_early_ids table. > > > > > > Signed-off-by: Lucas De Marchi > > > > I don't know the details of stolen memory, but the implementation of > > this quirk looks good to me. Very nice that it's now very clear > > exactly what the change is. > > > Reviewed-by: Rodrigo Vivi > > Bjorn, ack to merge through drm-intel? This is a bit of a shared area between the x86 folks and me, but certainly no objection from me. Acked-by: Bjorn Helgaas > > > --- > > > > > > v3: now that we do the refactor before the fix, we can do a single line > > > change to fix intel_graphics_quirks(). Also, we don't change > > > intel_graphics_stolen() anymore as we did in v2: we don't have to check > > > other devices anymore if there was a previous match causing > > > intel_graphics_stolen() to be called (there can only be one integrated > > > GPU reserving the stolen memory). > > > > > > arch/x86/kernel/early-quirks.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c > > > index df34963e23bf..932f9087c324 100644 > > > --- a/arch/x86/kernel/early-quirks.c > > > +++ b/arch/x86/kernel/early-quirks.c > > > @@ -609,8 +609,6 @@ static void __init intel_graphics_quirks(int num, int slot, int func) > > > if (quirk_applied) > > > return; > > > > > > - quirk_applied = true; > > > - > > > device = read_pci_config_16(num, slot, func, PCI_DEVICE_ID); > > > > > > for (i = 0; i < ARRAY_SIZE(intel_early_ids); i++) { > > > @@ -623,6 +621,8 @@ static void __init intel_graphics_quirks(int num, int slot, int func) > > > > > > intel_graphics_stolen(num, slot, func, early_ops); > > > > > > + quirk_applied = true; > > > + > > > return; > > > } > > > } > > > -- > > > 2.34.1 > > >