From owner-freebsd-current@freebsd.org Wed May 27 21:38:26 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 C3B072F0241 for ; Wed, 27 May 2020 21:38:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) 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 49XPMk4qbDz4C0P for ; Wed, 27 May 2020 21:38:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: by mailman.nyi.freebsd.org (Postfix) id A384D2F00BB; Wed, 27 May 2020 21:38:26 +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 A33E52F02B2 for ; Wed, 27 May 2020 21:38:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49XPMk3yb0z4BRX; Wed, 27 May 2020 21:38:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-274.local (unknown [IPv6:2601:648:8203:2990:7455:e867:e594:d678]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id DFC611D7DD; Wed, 27 May 2020 21:38:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: acpi timer reads all ones [Was: efirtc + atrtc at the same time] To: Hans Petter Selasky , Justin Hibbits Cc: Andriy Gapon , Konstantin Belousov , FreeBSD Current 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> <20200527084107.671238bb@titan.knownspace> <41192c31-f377-0517-5fa6-ec712313d7ea@selasky.org> From: John Baldwin Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: Date: Wed, 27 May 2020 14:38:24 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <41192c31-f377-0517-5fa6-ec712313d7ea@selasky.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 21:38:26 -0000 On 5/27/20 2:05 PM, Hans Petter Selasky wrote: > On 2020-05-27 15:41, Justin Hibbits wrote: >> 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. > > Is this perhaps related to: > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237666 No. I get that constantly on a desktop that never suspends/resumes. It only started after upgrading to 12.0. -- John Baldwin