From nobody Wed Apr 27 13:47:10 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 07FB31993B76; Wed, 27 Apr 2022 13:47:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KpKmt6jr5z3DPG; Wed, 27 Apr 2022 13:47:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651067231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aKY4JGX0K49iztJUiA+CJmStHIrCHX324/aqgiEnLjo=; b=LmoplROACdXMFjMOWBXPkIVOvN+2G2WIhUx+nxBs9/ai6/fYFEVVO/9ij9NsvomLN3SPcM JB/IDDIKx8VbeJmpkLKsFid1/bDr2gsH1xj5MspFW9OO8rGIieardGH+10gLYYLCJB+tIh TU6mBReuKo2H4I+5d/9+Ac6wWwDP5bTEBLEPJD3DyDvBt7r6GjFAkloRfvBtkvG3v7KV5T FrAoaiLzslg1QHZ8WY7WewW+JcKUFesZUbHenoa1U0Mb/0PY/1ValYVo670vJT3Ld8sAMP wiSdtsU13CValMfE7DxjtO977H8iQ9pQkm/dBAErv4l9K6/FkTWLNwXeEdcZwA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BD34724EE3; Wed, 27 Apr 2022 13:47:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23RDlAok085532; Wed, 27 Apr 2022 13:47:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23RDlAg6085531; Wed, 27 Apr 2022 13:47:10 GMT (envelope-from git) Date: Wed, 27 Apr 2022 13:47:10 GMT Message-Id: <202204271347.23RDlAg6085531@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 972ea9cc57fd - stable/13 - hpet: Allow a MMIO window smaller than 1K List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 972ea9cc57fd9c13c118dab0d8797e6716fdc171 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651067231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aKY4JGX0K49iztJUiA+CJmStHIrCHX324/aqgiEnLjo=; b=LygGIYJo3bytoQDpLVAfSwsHUM3xwyyGZl9Zd4Zr4IVaJs6Ln0iGOsqnFz9KRmbxqbaqd0 Tyxgy9PmLnIfmdbkbj6TCqk4G0gf2mOjVXz1IfnMazJo5dhpt0jbsK0lrImtPB/LIK8kuj vt+LkGs708wlLu4rzEYFlZfz2771F0+sWYdRcTpA5/bN9CjOCuKoZhWBPRSJ/xHDFHDPRu BGNd606lWleRBxqBeHEvTY4gyjF1QS8Z+Aa1fVV5O1P0Uf2YPG8A9kt3wRpitJk2Uw8hQx GzR7xX96vA0cxUzYoJqYJEK2rcpXVR5RC3oADLnGpdbJ+4iKg9Bb49AjEIqmoA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651067231; a=rsa-sha256; cv=none; b=hneVtObG41RCLDYw0xW6vTQ99MMrpDmG5limUwZM46xenhDiQc7OqTbBRa9KgGjG9mhrSn SLv3bBP9hUuR7YnmzEYPL5BAC34ibKeWX7G+a4iwtYQj/Ker66t1A4W4/3So4CTsWAhSRC oO0tvXfxBuxvIbqX0JB8TaF7Lj5rDgRZbRHJGrspHPE36OUJ/aDDR20Gb23qirgFRX/lV5 kFrbfcRoeO+930LdHV2U7iWMomjXeNEScYNHY0ONwQ5gv9ANdtYJa+u/cMTtiIUqNBV2GZ mH2M9cdu8HNcMnDVFZcfbZ6emVTo8xvFd5qOaMmd+bbfeaic8/EeB/Kkuq9Ygg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=972ea9cc57fd9c13c118dab0d8797e6716fdc171 commit 972ea9cc57fd9c13c118dab0d8797e6716fdc171 Author: John F. Carr AuthorDate: 2022-03-19 22:51:43 +0000 Commit: Mark Johnston CommitDate: 2022-04-27 13:33:56 +0000 hpet: Allow a MMIO window smaller than 1K Some new AMD systems provide a HPET MMIO region smaller than the 1KB specified, and a correspondingly small number of timers. Handle this in the HPET driver rather than requiring a 1KB window. This allows the HPET driver to attach on such systems. PR: 262638 Reviewed by: markj (cherry picked from commit 964bf2f902c5e05381018532e5d9d456979d4bf7) --- sys/dev/acpica/acpi_hpet.c | 20 +++++++++++++++++--- sys/dev/acpica/acpi_hpet.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c index 0f0a16f336f2..e35e3808a980 100644 --- a/sys/dev/acpica/acpi_hpet.c +++ b/sys/dev/acpica/acpi_hpet.c @@ -477,6 +477,7 @@ hpet_attach(device_t dev) struct make_dev_args mda; int i, j, num_msi, num_timers, num_percpu_et, num_percpu_t, cur_cpu; int pcpu_master, error; + rman_res_t hpet_region_size; static int maxhpetet = 0; uint32_t val, val2, cvectors, dvectors; uint16_t vendor, rev; @@ -493,10 +494,11 @@ hpet_attach(device_t dev) if (sc->mem_res == NULL) return (ENOMEM); - /* Validate that we can access the whole region. */ - if (rman_get_size(sc->mem_res) < HPET_MEM_WIDTH) { + hpet_region_size = rman_get_size(sc->mem_res); + /* Validate that the region is big enough for the control registers. */ + if (hpet_region_size < HPET_MEM_MIN_WIDTH) { device_printf(dev, "memory region width %jd too small\n", - rman_get_size(sc->mem_res)); + hpet_region_size); bus_free_resource(dev, SYS_RES_MEMORY, sc->mem_res); return (ENXIO); } @@ -526,6 +528,18 @@ hpet_attach(device_t dev) */ if (vendor == HPET_VENDID_AMD && rev < 0x10 && num_timers > 0) num_timers--; + /* + * Now validate that the region is big enough to address all counters. + */ + if (hpet_region_size < HPET_TIMER_CAP_CNF(num_timers)) { + device_printf(dev, + "memory region width %jd too small for %d timers\n", + hpet_region_size, num_timers); + hpet_disable(sc); + bus_free_resource(dev, SYS_RES_MEMORY, sc->mem_res); + return (ENXIO); + } + sc->num_timers = num_timers; if (bootverbose) { device_printf(dev, diff --git a/sys/dev/acpica/acpi_hpet.h b/sys/dev/acpica/acpi_hpet.h index c3941c39a89a..1d6a6022230e 100644 --- a/sys/dev/acpica/acpi_hpet.h +++ b/sys/dev/acpica/acpi_hpet.h @@ -30,6 +30,7 @@ #define __ACPI_HPET_H__ #define HPET_MEM_WIDTH 0x400 /* Expected memory region size */ +#define HPET_MEM_MIN_WIDTH 0x100 /* Minimum memory region size */ /* General registers */ #define HPET_CAPABILITIES 0x0 /* General capabilities and ID */