From nobody Fri Jan 19 16:36:03 2024 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 4TGlc370ZNz56rcs; Fri, 19 Jan 2024 16:36:03 +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 4TGlc36BgPz4657; Fri, 19 Jan 2024 16:36:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705682163; 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=mOyoDU38G/PzsDp0RYo6dv7Cw1TJSYfesTIpujoTVgs=; b=EECYCFANxwmfq/OWy2J2/dnqeC8CeQ8UKld/OkfH0YvDnIwFK6Q7d3r411h0McErUypnzZ wqO09Mdh/aaE5BDcLwd/odO56WERaMOqBBuRuE+8Rk00WBKy/SV9Kwfcw2gz6+BrdLNykD t1ElmYSGPGplciNC0RYRODn4JEq2OxatIWI/+1a61a2FU7/XIBYL+N6/EwqWLswokwlaag ntPYx122a0gEFMXVb/HhnN7YhELiHR2TKfX1z3XKKxiGsYt9EPJTa0npiMIU3i94YPCi8i 040iFm6fauYliHN9x/KDB11HvWaSHGNILLIxMoWX77kcpwqsVUs3tkeNwK2BtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705682163; 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=mOyoDU38G/PzsDp0RYo6dv7Cw1TJSYfesTIpujoTVgs=; b=JDUL/kXpjEC4LNn4xslEaFG37Bct2g+C2LwGt18lCNntf54hb3Ux7ern4n5AKEQ7Z6KONE Hcev08II9rdocb8ynx1JsdMtqEtrk1ExQ3W5RimS5hsA5R8lpgcOsFhIfv6mxaoeVTkMyd QLwjluOaWT+XvU1OLOkmexB4t83pH3+jA03wlMnG1tiPl3VYX8pZkE79zMKaMDqJA6E0F2 jbkgsyks60B6UJ1RBH0X757XIr61SE5At88H9F5rFNP/S+lgEU5ewtMvO7KV7gjuYK/Zdx sItZXTTS/PsrAlSwN3hycqDs6509bNVNQSAvjRgWFMLo++vyNh8C99JQXnBFDw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705682163; a=rsa-sha256; cv=none; b=G4XGg2nxpH690mRWxsVXMgVZwAaByFM/cI1LOP0PZ4aRx48/aF4gohEGzkkXiJUC3aCJYe MATlBYRYAVL3NRCkBFjpEpA/6XTBd4aQ8xBH/G4MVxxWw3sX5TtJRCulHKQ7vK5u69SWs5 5e0yK2PaLCysRH+kJ5dJ65iWKrUct/OeO2xQ5UH2Bs03kgak9Z8mGPiE9hWSo0f5WixSbq /7qeIVNQFCMy4mSBIPLAgcx8sspYsU4MLV/5V2HpfMSNv/h24bqHIWQ9Uuy5foU6apMMmY +wY/0veawUudrmxlOO50II7PixWTxU6rI5MYha+U5dZf/psEfDhVduZXeZZFnA== 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 4TGlc35JNRzypy; Fri, 19 Jan 2024 16:36:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40JGa3oU026521; Fri, 19 Jan 2024 16:36:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40JGa389026518; Fri, 19 Jan 2024 16:36:03 GMT (envelope-from git) Date: Fri, 19 Jan 2024 16:36:03 GMT Message-Id: <202401191636.40JGa389026518@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: c71b398a1555 - stable/13 - acpi_cpu: Reduce BUS_MASTER_RLD manipulations 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c71b398a155579d3bd31b3945013488bac5cb41e Auto-Submitted: auto-generated The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c71b398a155579d3bd31b3945013488bac5cb41e commit c71b398a155579d3bd31b3945013488bac5cb41e Author: Alexander Motin AuthorDate: 2023-12-26 02:19:28 +0000 Commit: Alexander Motin CommitDate: 2024-01-19 16:35:54 +0000 acpi_cpu: Reduce BUS_MASTER_RLD manipulations Instead of setting and clearing BUS_MASTER_RLD register on every C3 state enter/exit, set it only once if the system supports C3 state and we are going to "disable" bus master arbitration while in it. This is what Linux does for the past 14 years, and for even more time this register is not implemented in a relevant hardware. Same time since this is only a single bit in a bigger register, ACPI has to do take a global lock and do read-modify-write for it, that is too expensive, saved only by C3 not entered frequently, but enough to be seen in idle system CPU profiles. MFC after: 1 month (cherry picked from commit 5bc10feacc9d81e3bba9d28734a85e996682b408) --- sys/dev/acpica/acpi_cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 395faf450188..1d5b93c304b0 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -512,6 +512,9 @@ static void enable_idle(struct acpi_cpu_softc *sc) { + if (sc->cpu_cx_count > sc->cpu_non_c3 + 1 && + (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) + AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1); sc->cpu_disable_idle = FALSE; } @@ -1164,14 +1167,13 @@ acpi_cpu_idle(sbintime_t sbt) } /* - * For C3, disable bus master arbitration and enable bus master wake - * if BM control is available, otherwise flush the CPU cache. + * For C3, disable bus master arbitration if BM control is available. + * CPU may have to wake up to handle it. Otherwise flush the CPU cache. */ if (cx_next->type == ACPI_STATE_C3) { - if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) { + if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 1); - AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1); - } else + else ACPI_FLUSH_CPU_CACHE(); } @@ -1206,12 +1208,10 @@ acpi_cpu_idle(sbintime_t sbt) else end_ticks = cpu_ticks(); - /* Enable bus master arbitration and disable bus master wakeup. */ + /* Enable bus master arbitration. */ if (cx_next->type == ACPI_STATE_C3 && - (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) { + (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 0); - AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 0); - } ACPI_ENABLE_IRQS(); if (cx_next->type == ACPI_STATE_C3)