From nobody Mon Mar 6 06:51:42 2023 X-Original-To: freebsd-hackers@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 4PVTlH68hKz3wWQ8 for ; Mon, 6 Mar 2023 06:51:55 +0000 (UTC) (envelope-from tomek@cedro.info) Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) (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 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PVTlH2Gn3z3qF7 for ; Mon, 6 Mar 2023 06:51:55 +0000 (UTC) (envelope-from tomek@cedro.info) Authentication-Results: mx1.freebsd.org; none Received: by mail-qt1-x835.google.com with SMTP id r5so9542623qtp.4 for ; Sun, 05 Mar 2023 22:51:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cedro.info; s=google; t=1678085514; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8GXc/rV6Gr6APNeMVwe2/jGL8qN1dqyw7BWEWugvIv8=; b=cUe1WtxIvJvLJrYRxqJ9ef0Ap3LpV1dHMNoCBy9fRClqfKxOlaG3tt5vNtZIHnxUTk VdAQXyxJS+UYTXIRWqeycZbfKVjYMO7TnQtwEeTj/SnGDGgtxLiGexI0Tx0rOsHccHK5 hU8lxQ3QKpBwkwaX+r6Dy5m6XdH8R7PUnhe6Qa2s2ZwU/vg4DCfSDBfPpIeZ5OBW6K+0 SIFtGmMF0SgvQa2QlRSB2U6/BnBITXMxrl7eYL+ML/JX/rLksRErzzpmLusFg7hMykSx uZUKyi0vwzkvsjbuyK9f3wugB/h73euU6WSBzimgCHyFbfk2K0O/+NNa9py5tD+TOHrH 2XEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678085514; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8GXc/rV6Gr6APNeMVwe2/jGL8qN1dqyw7BWEWugvIv8=; b=BAP1TZAOAp3ztKOhQPPQGofkslkPGAMsxK5BbI4Im4zJfRMBqEEUfSgbBMdOQQNAKa fqF4o6YJiBRigMH/FmULOypvBI58851HGrOhPtJv55pqUFsv98HKsbA+RScLIjWalb2B Qz72PPW3TwKjF3K/ii7MKVRXbFyfH1JvtuDvHgqnqpzBWXP8JXr8goqVkha8Jy1j9YGj 8YKrtmGVvR8GJVe87r2MxHFbMTK2vTAjVRO6motoy2CDen0E9adR4zw6gfX6k/D+46I9 2TNWXmI6dr9coC52UGO4LYTGgZddD0rvX2U0ngv2FQ9bs6fCCIREWVsyJG8k/vzxpsSz WZRQ== X-Gm-Message-State: AO0yUKWprxlpjpAdPNxWhsxtyhfVqabVTaKRUnVgBdoKSnXxtqrAJ1K0 NTCIHKMt7draNP2K+K5LAI1M/w== X-Google-Smtp-Source: AK7set9X4gqrdjHG5Y9bRBlmYhp9U1ozberYmTzEeJ37iUW8Oq3bEvmApADl3A52OrYkIan/pFel5A== X-Received: by 2002:a05:622a:130e:b0:3b9:b6b7:90c5 with SMTP id v14-20020a05622a130e00b003b9b6b790c5mr15695584qtk.49.1678085514379; Sun, 05 Mar 2023 22:51:54 -0800 (PST) Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com. [209.85.219.176]) by smtp.gmail.com with ESMTPSA id m18-20020ac866d2000000b003bfbfd9a4aesm6994473qtp.56.2023.03.05.22.51.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 05 Mar 2023 22:51:54 -0800 (PST) Received: by mail-yb1-f176.google.com with SMTP id t39so7093880ybi.3; Sun, 05 Mar 2023 22:51:53 -0800 (PST) X-Received: by 2002:a5b:bc6:0:b0:a0d:8150:be04 with SMTP id c6-20020a5b0bc6000000b00a0d8150be04mr4545792ybr.13.1678085513610; Sun, 05 Mar 2023 22:51:53 -0800 (PST) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Tomek CEDRO Date: Mon, 6 Mar 2023 07:51:42 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: acpi_cmbat with charge-limited battery To: Kyle Evans Cc: Warner Losh , FreeBSD Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4PVTlH2Gn3z3qF7 X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On Mon, Mar 6, 2023 at 7:39=E2=80=AFAM Kyle Evans wrot= e: > On Sun, Mar 5, 2023 at 9:33=E2=80=AFPM Warner Losh wrote= : > > On Sun, Mar 5, 2023 at 7:20=E2=80=AFPM Kyle Evans = wrote: > >> > >> Hello! > >> > >> I've dealt with this mainly over the weekend, but my solution was to > >> just disable acpi_cmbat entirely, which is maybe not the best solution > >> but I can't tell if this should be considered a firmware bug or if > >> it's something we could find a way to workaround in the kernel. > >> > >> Basically, I've set the firmware on my frame.work laptop to limit the > >> battery charge to 80%. When it hits 80% while plugged in, things get a > >> little funky- I assume it's because the firmware's trying to carefully > >> maintain the limit, but I end up getting (at least) one acpi > >> notification per second, alternating between BST_CHANGE/BIX_CHANGE, > >> which in turn drives up CPU usage as we tap it out to devd and upowerd > >> picks it up. upowerd ends up pegging a core consistently. > >> > >> Should we be rate-limiting these devd notifications? Is this even > >> reasonable behavior for the firmware? I'm not really sure how other OS > >> behave here, but I haven't really seen any complaints from other > >> framework'ers. > > > > Seems like this is crappy firmware behavior and we should rate > > limit in the driver... It's not useful information to be sharing once > > a second... > > The more I think about it (and with your generally confirmatory > response), the more I think approaching both problems independently is > probably good. I added a quick sysctl to acpi_cmbat to allow an > interval for folks with broken firmware like myself; I'll probably > throw that up for review tomorrow-ish. I'll also reach out to > frame.work folks and see if they can improve this in some way, but I > suspect any action there will take a while. Maybe some sort of PID function would help separate data and control? :-) https://en.wikipedia.org/wiki/PID_controller --=20 CeDeROM, SQ7MHZ, http://www.tomek.cedro.info