From nobody Mon Apr 14 16:10:20 2025 X-Original-To: dev-commits-src-branches@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 4ZbshD5DfWz5t3mr; Mon, 14 Apr 2025 16:10:20 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZbshD4hrDz44XW; Mon, 14 Apr 2025 16:10:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744647020; 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=N/rqc0xqIysnTB/48sNCB+Vwhz8GO/UDPuybvWTQA50=; b=aeyXxWQKpNAW4Rthv0R7ncf/aSxIgkxi8PtBvJeW2U/ttKF5zHlfswtBmYklJXyJ6A8y0C Brx8kW9jd+9nnWiHZV27LY2XyLIs0Nig8cuW6Xu0iShik/Vw+JotZpHm0RzHnesu4wCHQh W9kZ5LDUtOkOii3Ee951/S9a7OoTMJmF/cIJP/GhteM3gr2mG+FzoZ+tP7MGIQY9BPhPh/ o7jnPsAPw+4gNfoyHh+AVkVtuYRo3lo0vj+PJmbkOA8qyM/H55Ja2qR05M4T7tvyY/ecxx k5iNdrABqUInxDnvMd1x7aL6h47eplwdrNBRc9q1DbB+V/4cavEY+lls2P2bAQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744647020; a=rsa-sha256; cv=none; b=NkRVupK05k4tR7d77pJoR0toYCxveP8hF93XAusSC2agTgukjohxNB93vIYdq7ahoRbO5h H5lW7rbJjy/9j8BaQV/Kh3efx48SWICVRDktCVNpXFFFB/KUXClIqxRhHgalVcYgsEQ8tG rvpqOUCD5GE7aFnqmOxsFvCtwPNLBtNKWzHYaorajmyED8tQRBNo6KGOeHCUwrta01hTG4 3kObWj+z4viX7G0uY/ZhguugiXdlmF7WOMQ5L2Lqb4v3Wp5PP6diMuQpegG48x7sVf2vqR ip3QAjIHnWNnM4DbU4XvSa3jJHP8wfu/XSOtGk+WGEf4eGJ/AHVk4+/2yBgZWQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744647020; 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=N/rqc0xqIysnTB/48sNCB+Vwhz8GO/UDPuybvWTQA50=; b=ee6KV/kyP1WwSdUB/JANq7/XoFjityrViUmN+bhVnVBxkVMofCgelvkGQBYJAmnMurtNKC W7OAr7dICgo0FKvOrg+mJbrbOGHmSRxJu35Xy+1p8kyW5JGaZKAR04/kuhnTLs3bC/sSGc vLO6ewHHNQ8JwbVY9A0avdhmO1eqFCZZSftR730NZy+QA8TTV8onXldVDBMTOrZSs0yXiH aN+3wEOAECsi4iMbU0B6WnJ+uoPtyBxPvNz7XUMk2Tb/hi5N/LZ5NqbVqet6bML7zGvOjZ dhRVUEI4xppWdrUynxmod0/wKQ0OZ+mwE997S+8VsEB4bVQaDzHPVYESMp+ktA== 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 4ZbshD3vBJzw4D; Mon, 14 Apr 2025 16:10:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53EGAK8W066276; Mon, 14 Apr 2025 16:10:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53EGAKuI066273; Mon, 14 Apr 2025 16:10:20 GMT (envelope-from git) Date: Mon, 14 Apr 2025 16:10:20 GMT Message-Id: <202504141610.53EGAKuI066273@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Colin Percival Subject: git: 43933d89a325 - stable/14 - acpi_pci: Add quirk for DELAY-after-EJ0 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 43933d89a3256f33d0eb29473ac56b3e0e7b9318 Auto-Submitted: auto-generated The branch stable/14 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=43933d89a3256f33d0eb29473ac56b3e0e7b9318 commit 43933d89a3256f33d0eb29473ac56b3e0e7b9318 Author: Colin Percival AuthorDate: 2025-03-06 05:22:33 +0000 Commit: Colin Percival CommitDate: 2025-04-14 16:09:49 +0000 acpi_pci: Add quirk for DELAY-after-EJ0 On some EC2 instances, there is a race between removing a device from the system and making the PCI bus stop reporting the presence of the device. As a result, a PCI BUS_RESCAN performed immediately after the _EJ0 method returns "sees" the device which is being ejected, which then causes problems later (e.g. we won't recognize a new device being plugged into that slot because we never knew it was vacant). On other operating systems the bus is synchronously marked as needing to be rescanned but the rescan does not occur until O(1) seconds later. Create a new ACPI_Q_DELAY_BEFORE_EJECT_RESCAN quirk and set it in EC2 AMIs, and add a 10 ms DELAY between _EJ0 and BUS_RESCAN when tht quirk is set. Reviewed by: jhb MFC after: 1 month Sponsored by: Amazon Differential Revision: https://reviews.freebsd.org/D49252 (cherry picked from commit 55c3348ed78fb1d0891e8bb51a8948f95da3560b) --- release/tools/ec2.conf | 5 +++-- sys/dev/acpica/acpi_pci.c | 2 ++ sys/dev/acpica/acpivar.h | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/release/tools/ec2.conf b/release/tools/ec2.conf index 21ea56d109ca..3675736ab986 100644 --- a/release/tools/ec2.conf +++ b/release/tools/ec2.conf @@ -68,8 +68,9 @@ ec2_common() { # (in fact the PL061 has no pullup/pulldown resistors). Graviton 1 # through Graviton 3 have non-functional PCI _EJ0 and need a value # written to the PCI power status register in order to eject a - # device. - echo 'debug.acpi.quirks="24"' >> ${DESTDIR}/boot/loader.conf + # device. EC2 instances with PCI (not PCIe) buses need a short + # delay before rescanning upon device detach. + echo 'debug.acpi.quirks="56"' >> ${DESTDIR}/boot/loader.conf # Load the kernel module for the Amazon "Elastic Network Adapter" echo 'if_ena_load="YES"' >> ${DESTDIR}/boot/loader.conf diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c index 97704111839b..b7a2bf70b4e0 100644 --- a/sys/dev/acpica/acpi_pci.c +++ b/sys/dev/acpica/acpi_pci.c @@ -432,6 +432,8 @@ acpi_pci_device_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) acpi_name(h), AcpiFormatException(status)); return; } + if (acpi_quirks & ACPI_Q_DELAY_BEFORE_EJECT_RESCAN) + DELAY(10 * 1000); BUS_RESCAN(dev); bus_topo_unlock(); break; diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 830764434f48..d35504127c9c 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -232,6 +232,8 @@ extern struct mtx acpi_mutex; * as "PullUp" and they should be treated as "NoPull" instead. * ACPI_Q_CLEAR_PME_ON_DETACH: Specifies that PCIM_PSTAT_(PME & ~PMEENABLE) * should be written to the power status register as part of ACPI Eject. + * ACPI_Q_DELAY_BEFORE_EJECT_RESCAN: Specifies that we need a short (10ms) + * delay after _EJ0 returns before rescanning the PCI bus. */ extern int acpi_quirks; #define ACPI_Q_OK 0 @@ -240,6 +242,7 @@ extern int acpi_quirks; #define ACPI_Q_MADT_IRQ0 (1 << 2) #define ACPI_Q_AEI_NOPULL (1 << 3) #define ACPI_Q_CLEAR_PME_ON_DETACH (1 << 4) +#define ACPI_Q_DELAY_BEFORE_EJECT_RESCAN (1 << 5) #if defined(__amd64__) || defined(__i386__) /*