From owner-freebsd-current@freebsd.org Wed May 27 13:41:12 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B6F5F333031 for ; Wed, 27 May 2020 13:41:12 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 49XBn42323z4P2t for ; Wed, 27 May 2020 13:41:12 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: by mailman.nyi.freebsd.org (Postfix) id 44646332DFC; Wed, 27 May 2020 13:41:12 +0000 (UTC) Delivered-To: current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 442B4332DFB for ; Wed, 27 May 2020 13:41:12 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49XBn36gp2z4Nrl; Wed, 27 May 2020 13:41:11 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: by mail-il1-x143.google.com with SMTP id d1so1495878ila.8; Wed, 27 May 2020 06:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sjnqa2dHUUZUVtu6NupvbIRioRN0wuJNEGB+0LDez+w=; b=DjBDAbCxLXKDGbs1V7RDMwR7DuUDsFsmkxKb8yh6a1F33yyOQ5+HhU55jpc+CmY4Tc uiWiIuAvrVAuKCCA3fdGSmzqjPCJo3cpmZvvAurvvOWWIeGYjs9K29I40JV535EZJBql /Kh4s5rtH4DgO+qzZ6HrL1gDt32NyqBFpX705lyS35cXYUvuxfSCeZ2kuPW20bLvlcl0 /7LoF3ZT5K9zsmQwSL+kOCI7UcXBErgdXVaFNdMfAxH5vW82j986v7B4yKtCyT9yo1vV 5IwXjLte43jk/vHpMvIhMUzIkgQXf1HdYZIaV16srSYSWl96ODDzfvqUbe1oxdGb+Twg +I/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sjnqa2dHUUZUVtu6NupvbIRioRN0wuJNEGB+0LDez+w=; b=TIVBSIkeiAWMWcAzQnRJICuwwBbPFJA/s0aJHKIbWH9i7fc5KRc2X7A/Woo7Nf/yAD ucii5YUzIi5u6CxoxMAASDvgzBdOqM7WvnngWyabmMmYl13A+FZN+paz+JcKXZwGy1cd rPhemwT5AheJmIRJUXbPGaz19lpKg8q1NJ+rxgpcX8tEacxgK62buOGBpvCHIX7z89ws cnAjYauKUmuDtGE/lzxNXhfSRx0pVf9cPo/iI5isxMG0SG5tOEpHUaIxNl/eQh1BKxFO UdmruVGVCQK2CRkCuBfDKqcUPsXwpwmDaAAZhknqRJzAl/Mt72/CckeV6xrGMQebKDes CsIw== X-Gm-Message-State: AOAM533tM04ngkXxH2/YuaTy3TcxRuSiiotD7437D11haDOd1w3UcPCN ZMh1UBBJ9MMOcUXp2YF2PWunbJDs9BeBrQ== X-Google-Smtp-Source: ABdhPJw6rLpn1CkX88rmLcKZLLzVuuKr0nJwt2oMB98HiNyn/Xz/K/buaoqtSzW5nUUqkcT0bxOcnw== X-Received: by 2002:a92:9154:: with SMTP id t81mr5736812ild.235.1590586870673; Wed, 27 May 2020 06:41:10 -0700 (PDT) Received: from titan.knownspace (173-19-125-130.client.mchsi.com. [173.19.125.130]) by smtp.gmail.com with ESMTPSA id p7sm1233586iob.7.2020.05.27.06.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 06:41:09 -0700 (PDT) Date: Wed, 27 May 2020 08:41:07 -0500 From: Justin Hibbits To: John Baldwin Cc: Andriy Gapon , Konstantin Belousov , FreeBSD Current Subject: Re: acpi timer reads all ones [Was: efirtc + atrtc at the same time] Message-ID: <20200527084107.671238bb@titan.knownspace> In-Reply-To: <618658d9-b892-9255-2747-c5efbada0210@FreeBSD.org> References: <021d8df4-a4f8-620d-73b6-b6103d0bf7f1@FreeBSD.org> <199c8845-e42c-fbee-3f13-0b3d0d7234dc@FreeBSD.org> <20200526185528.GA48478@kib.kiev.ua> <114f788a-3947-0783-5472-173cf3a30d32@FreeBSD.org> <618658d9-b892-9255-2747-c5efbada0210@FreeBSD.org> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; powerpc64-portbld-freebsd13.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 49XBn36gp2z4Nrl X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; REPLY(-4.00)[] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 May 2020 13:41:12 -0000 On Wed, 27 May 2020 06:27:16 -0700 John Baldwin wrote: > On 5/27/20 2:39 AM, Andriy Gapon wrote: > > On 27/05/2020 11:13, Andriy Gapon wrote: > >> I added more diagnostics and it seems to support the idea that the > >> problem is related to I/O cycles and bridges. > >> > >> ACPI timer suddenly starts returning 0xffffffff and that lasts for > >> tens of microseconds before the timer goes back to returning > >> normal values with an expected increase. > >> AMD provides a proprietary way to access ACPI registers via MMIO > >> (0xfed808xx). That mechanism is unaffected, ACPI timer register > >> always returns good values. > >> > >> The problem seems to happen when restoring configuration of a > >> particular PCI bridge. What's interesting is that the bridge > >> decodes one memory range and one I/O range. > >> > >> Looking at pci_cfg_restore() I wonder if it is wise to restore > >> PCIR_COMMAND so early. Could it be that after the resume the > >> bridge is configured with a wrong I/O range (e.g., too wide) and > >> by writing PCIR_COMMAND we enable that decoding. So, the bridge > >> steals I/O cycles destined for ACPI support hardware. If there is > >> nothing behind the bridge to handle those ports, then we get those > >> bad readings. Once the bridge configuration is fully restored, the > >> I/O handling goes back to normal. > > > > From what I see, this looks like a BIOS bug. > > Upon resume, it swaps window configurations of pcib1 and pcib2 > > (until FreeBSD restores them). pcib1 originally does not have an > > I/O window. So, BIOS programs both base and limit of pcib2 I/O > > window to zero. When FreeBSD writes its command register to > > enable I/O decoding it starts claiming 0x0 - 0xFFF I/O port range. > > That covers the ACPI ports at 0x8xx. > > > > Some printf-s. > > From (verbose) boot time: > > pcib1: domain 0 > > pcib1: secondary bus 1 > > pcib1: subordinate bus 1 > > pcib1: memory decode 0xfea00000-0xfeafffff > > pcib2: domain 0 > > pcib2: secondary bus 2 > > pcib2: subordinate bus 2 > > pcib2: I/O decode 0xf000-0xffff > > pcib2: memory decode 0xfe900000-0xfe9fffff > > > > My printf-s from resume time: > > pcib1: old I/O base (low): 0xf1 > > pcib1: old I/O base (high): 0x0 > > pcib1: old I/O limit (low): 0x1 > > pcib1: old I/O limit (high): 0x0 > > pcib2: old I/O base (low): 0x1 > > pcib2: old I/O base (high): 0x0 > > pcib2: old I/O limit (low): 0x1 > > pcib2: old I/O limit (high): 0x0 > > The "solution" I think is to have resume be multi-pass and to resume > all the bridges first before trying to resume leaf devices (including > timers), but that's a fair bit of work. It might be that we just > need to resume timer interrupts later after the new-bus resume (I > think we currently do it before?), though the reason for that was to > allow resume methods in devices to sleep (I'm not sure if any do). > That sounds like a good fit for https://reviews.freebsd.org/D203 . Someone (TM) just needs to take it over the finish line... 6 years later. - Justin