Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1788764pxb; Wed, 9 Feb 2022 04:39:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCUzDLATSmqaEVdfdbeLYylvfs5ATExQWgouGijrvVlhRvBtkHEj4mVrApWfj84+RaXJOL X-Received: by 2002:a17:907:9852:: with SMTP id jj18mr1764977ejc.467.1644410352779; Wed, 09 Feb 2022 04:39:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644410352; cv=none; d=google.com; s=arc-20160816; b=b3wZsQwpaa9mJ8ClwEVRXgjvMQk9RZmv+4ygpHNymOCzrX2pMWLjhon6HQ6oOaQHSE p/wNhOZfoAUPUj7ivpjY4Bme2iMGXucbE52FJJuYVXhfPTgMFbWBkQHfFIR6qNRzl9p4 jLiO8pPTaGVQJeut4tZs3t3KpoFQNNVinfHeNpm1ZfkfNIIqAfFpP6lPAWsXqmK7OVOc QUcrf46rMESv/Lgpy5FQo2aIQ3oMAyjg7m/BGTGWVZBEtW/QCL+3Za5IozFokc666Cu+ bZS/hC50mHmN/j+oCWsSfBOfrHnpU5XUOCUb6v03h9c28MtVJkQhkVmdUPfZrbnNegKF ayrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=x9aTgWorxmOMZ/GRWx8E/Y5Yeg9z/vdWCDtKaFrhYAk=; b=wsn0pX0VgCaUUo+kJHFoK6RiI9YT3c3ixkyXUY0GYKgMQpEMI9bTQXWIs+jzIapfBv DB1/EpUOb0GfNTer3U2yhOGmPhumRsB5dgqIiPGFUPOLWAYSgNHoWhueXwOeTqxgalhm 1eCN/P1en6RLW0LUZ/cfLoU2DXg6ZxFzqybo/34gZzlqM6wCcw10I8R3Mo0dwZT4yR4v VzXn6WNLdGTGVKtS+cnFqWiKiMOWZQweR4btVL7orKyhtn2QrfIqlkwFMT+syMS53R/B A/nwXEo7gWyjW9vam4rR0lM6FUgOnSNUWafyyUKjj3tHCmfTgWTfei2ss4yx8+nBWod9 Tg8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cSVMo0Bd; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si14894109edc.413.2022.02.09.04.38.47; Wed, 09 Feb 2022 04:39:12 -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=@redhat.com header.s=mimecast20190719 header.b=cSVMo0Bd; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232841AbiBIMXo (ORCPT + 99 others); Wed, 9 Feb 2022 07:23:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232881AbiBIMVr (ORCPT ); Wed, 9 Feb 2022 07:21:47 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 32C35C03544D for ; Wed, 9 Feb 2022 04:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644409095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x9aTgWorxmOMZ/GRWx8E/Y5Yeg9z/vdWCDtKaFrhYAk=; b=cSVMo0BdSk6b9Wwpu0wnUgrcxW0qbLLaW/QQyG/R12NlHjWILBVgrr1Ul4SDgjxCS8ZB4Y Sg0yTmj4W8AjEP7XefYGReOYmQHhJLEIKdG48BQIzCZSpetLJYjudNKjKeBdKeV0k3wKPU pOKsY3m4pF1JmEyEs1J+ts0gEajRquQ= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-x_Lv4V0EMhWDNUBUSzrvUA-1; Wed, 09 Feb 2022 07:18:13 -0500 X-MC-Unique: x_Lv4V0EMhWDNUBUSzrvUA-1 Received: by mail-ej1-f70.google.com with SMTP id h22-20020a1709060f5600b006b11a2d3dcfso1106489ejj.4 for ; Wed, 09 Feb 2022 04:18:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=x9aTgWorxmOMZ/GRWx8E/Y5Yeg9z/vdWCDtKaFrhYAk=; b=ELJxQtNb5kh72+FwKnZaiUA3xjhgNH8fqco30sIpLVdggLho3ukNFFZfbS026wxH02 sWU0giTVw3hYCrIBpmoUbharDerPv9V7RrWUTsXSRiAqNvsv38iZmMN4JPgZHagbYzGu f//fgR/byIzQFiMoCr2+rsbRze19UXlHTLmKdfWj4PYqrBTbxO0mVd/4xahOIiP2aKno dVqazCYjRqZ66uTpgZIAbsG/m3m5WOWbPMTa2p0np5o3ERciZ4ApEMT0WhuvWOtIVQi1 D6giVM7JGkWLWJ+V6YnC8dd6qgtphSAMe3qli1Itq0IecN7DUPcZEDB4KI40oU9LrxI9 YtjQ== X-Gm-Message-State: AOAM530gC/E8FR+O7aDFLE16PzwF4GOYHQTw2u3b2CpmtmUi5KnlhFbp DYfGOhW/o2Q2eBQ28QK7KY4vcdLw2QEvIm0OL8X1Hy6AdDm9o6PBgOkZXIp3mNr2V8YaHMm54LV nx8qSNSqPEc45VuLD6FQsk9gt X-Received: by 2002:a17:907:6284:: with SMTP id nd4mr1615548ejc.477.1644409092646; Wed, 09 Feb 2022 04:18:12 -0800 (PST) X-Received: by 2002:a17:907:6284:: with SMTP id nd4mr1615523ejc.477.1644409092423; Wed, 09 Feb 2022 04:18:12 -0800 (PST) Received: from ?IPV6:2001:1c00:c1e:bf00:1db8:22d3:1bc9:8ca1? (2001-1c00-0c1e-bf00-1db8-22d3-1bc9-8ca1.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:1db8:22d3:1bc9:8ca1]) by smtp.gmail.com with ESMTPSA id kw5sm6043359ejc.140.2022.02.09.04.18.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 04:18:11 -0800 (PST) Message-ID: <8dfcd932-b029-2bfe-2134-dd0182618cd7@redhat.com> Date: Wed, 9 Feb 2022 13:18:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [5.17 regression] "x86/PCI: Ignore E820 reservations for bridge windows on newer systems" breaks suspend/resume Content-Language: en-US To: Mika Westerberg Cc: "Rafael J. Wysocki" , Bjorn Helgaas , =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Myron Stowe , Juha-Pekka Heikkila , Ingo Molnar , Borislav Petkov , linux-acpi , Linux PCI , x86@kernel.org, Linux Kernel Mailing List , =?UTF-8?Q?Benoit_Gr=c3=a9goire?= , Hui Wang References: <697aaf96-ec60-4e11-b011-0e4151e714d7@redhat.com> From: Hans de Goede In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mika, On 2/8/22 17:38, Mika Westerberg wrote: > Hi Hans, > > On Tue, Feb 08, 2022 at 04:59:13PM +0100, Hans de Goede wrote: >> Hi, >> >> On 2/8/22 16:25, Hans de Goede wrote: >>> Hi All, >>> >>> Unfortunately I've just learned that commit 7f7b4236f204 ("x86/PCI: >>> Ignore E820 reservations for bridge windows on newer systems"): >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7f7b4236f2040d19df1ddaf30047128b41e78de7 >>> >>> breaks suspend/resume on at least one laptop model, the Lenovo ThinkPad >>> X1 gen 2, see: >>> https://bugzilla.redhat.com/show_bug.cgi?id=2029207 > > :-( Agreed. >>> This regression was actually caught be Fedora already carrying this >>> patch for a while now and as such it has been reproduced with 5.15 >>> with an older version of the patch which still allowed turning the >>> new behavior of by adding "pci=use_e820". Dmesg output with and >>> without the option has just been attached to the bug, I've not >>> analyzed this any further yet. >>> >>> I guess that for now this means that we need to revert commit >>> 7f7b4236f204. Rafael, I'll send you a revert with a commit msg >>> explaining why this needs to be reverted tomorrow. >>> >>> More interesting IMHO is finding out another solution. Both the touchpad >>> problem which got me looking into this: >>> https://bugzilla.redhat.com/show_bug.cgi?id=1868899 >>> >>> As well as the thunderbolt hotplug issue Mika was looking at: >>> https://bugzilla.kernel.org/show_bug.cgi?id=206459 >>> >>> both are cases where we fail to find a memory-window for a >>> BAR which has not been setup yet. >>> >>> So I see a couple of options here: >>> >>> 1. Detect that the e820 reservations fully cover (one of) >>> the PCI bridge main 32 bit memory windows and if that happens >>> ignore them. This actually was my first plan when I started >>> working on this. In the end I choose the other option >>> because Bjorn indicated that in hindsight honoring the e820 >>> reservations might have been a mistake and maybe we should >>> get rid of honoring them all together. >>> >>> 2. Have a flag which, when we fail to alloc a 32 bit >>> (or 64 bit) memory PCI BAR, is set if not already set >>> and then retry the alloc. And make the e820 reservation >>> carve-out get skipped in this case. >>> >>> 3. When booting with pci=nocrs as a workaround for >>> the touchpad case a 64 but memory window ends up getting >>> used. There already is some special handling for some >>> AMD bridges where if there are no 64 bit memory Windows >>> in the _CRS for the bridge, one gets added. Maybe we need >>> to do the same for Intel bridges ? >> >> 4. It seems that all devices which have issues with allocating >> a PCI bar are Ice Lake based; and the model where the ignoring >> of e820 reservations has been reported to cause issues is somewhat >> old. It is a Haswell, but still getting BIOS updates causing >> the BIOS date check to enable the new behavior. So another >> solution might be to only ignore e820 reservations on machines >> with Intel Ice Lake (and presumably also Tiger Lake) CPUs. >> >> >> 5. It also seems that the troublesome e820 entry on all devices >> ends at 0xcfffffff and starts well below 0x8000000 : >> >> Yoga C940: >> [ 0.000000] BIOS-e820: [mem 0x000000004bc50000-0x00000000cfffffff] reserved >> >> IdeaPad 3 15IIL05: >> [ 0.000000] BIOS-e820: [mem 0x000000004bc50000-0x00000000cfffffff] reserved >> >> Lenovo IdeaPad 5 14IIL05: >> [ 0.000000] BIOS-e820: [mem 0x000000005bc50000-0x00000000cfffffff] reserved > > I don't remember the details anymore but looking at the commit log of my > "fix" attempt here: > > https://bugzilla.kernel.org/attachment.cgi?id=287661 > > The EFI memory map actually seems to consists of several entries that somehow > are merged by something (I think this is the EFI stub but not sure). Booting > with "efi=debug" may help us to understand this further (or not). > > On that Yoga system, this: > > [Reserved | | | | | | | | | |WB|WT|WC|UC] range=[0x000000002bc50000-0x000000003fffffff] (323MB) > [Reserved | | | | | | | | | |WB| | |UC] range=[0x0000000040000000-0x0000000040ffffff] (16MB) > [Reserved | | | | | | | | | | | | | ] range=[0x0000000041000000-0x00000000453fffff] (68MB) > [Memory Mapped I/O |RUN| | | | | | | | | | | |UC] range=[0x0000000045400000-0x00000000cfffffff] (2220MB) > > became this: > > BIOS-e820: [mem 0x000000002bc50000-0x00000000cfffffff] reserved > > Since the area (0x45400000-0xcfffffff) is marked as MMIO I think maybe we can > simply skip those areas in arch_remove_reservations() or so? > > I may be missing a lots of details, though. ;-) Oh, I just did some initial digging through the source code and indeed on EFI there is no actual e820 memory map at all instead it gets faked to be able to re-use the BIOS boot based e820 code in the kernel by do_add_efi_memmap() from arch/x86/platform/efi/efi.c . And that does: switch (md->type) { ... default: /* * EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE * EFI_RUNTIME_SERVICES_DATA EFI_MEMORY_MAPPED_IO * EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE */ e820_type = E820_TYPE_RESERVED; break; Which seems to be the root cause of the problems, at least on the Yoga C940, but I expect on the others too (will try to get that confirmed). So yes this seems like a very promising solution direction actually. I will try to see if I can find a test-machine here in my home office with an EFI memmap entry with a MMIO type and then see if I can come up with a patch to make arch_remove_reservations() not exclude those areas. Regards, Hans