From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F81D37B402 for ; Wed, 20 May 2026 21:18:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779311902; cv=none; b=MN3Z7ErD6/i9hcvJCacuDHOSMBogK40Jg22RxZ6Iu3XUxb6Hbw/zUk1Ydrl4ayWMJ0dMTw2oXqMJfEmSnPWH6EBBOwtQHxtcaWheHRsZYI6bDSxKHbOx6vAUzr2XtSWSBL8SxkrZbT3+xBRVKrwv9ZrG1zo72V57z8gOD5vJr0o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779311902; c=relaxed/simple; bh=2qBAJakZ99cnOL/2UwFpo8VxRhNqhAyyDd3DXmJ7Fcc=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=o5dQ0kMQM5VeqhsB/Xni9hQT4Xa8NJJR+o9Er0nbppVfxBxiu8zG0xBMTKmJ3vN2X9McmmYVCE8PJwZws/KdOfMWXrtJ+UsCdohVojIlR53QYnyXP8TvpzRrR0DRZoE6uDR49MrE3ozHg1JofrtbrGXA4TybqmuSJA1d2MZhHYs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai; spf=pass smtp.mailfrom=nexthop.ai; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b=Yf8PAX5P; arc=none smtp.client-ip=74.125.82.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b="Yf8PAX5P" Received: by mail-dl1-f46.google.com with SMTP id a92af1059eb24-12ddbe104ccso3865938c88.0 for ; Wed, 20 May 2026 14:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1779311900; x=1779916700; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9Tf2Xd147xJ0sNfv/d8vxtKV4pEk11pNA8lNnJlbJZM=; b=Yf8PAX5PGIAB+58vF1DTGHYBfhfzNuCxJkKOhA/X4nILwk5+ll+fuR0YF+64WfTHkr 3l9cAhZzeMxMMladx+FkF5vtnWfn6cOW7YqCt6ficI3TVA6CrwkHUEQ0biO6f7qV3GkP 9L7Xg96mtLUmjB9GnHgZM6jBHg6/hHCD6/wIdldxHNLckT7t1onOlxf7w0kzc5wFudIY bX55Xgqks/9Oj/MA3orWI1LBpVAWVoHHuWysODNRKUJtugUA81+XD6FL8JhH7JgCcKJM VG4VmkjVrAXzrRT0TjMRkoPA8HWfs2JwMbqXffqoHZ8q03JywRcXJWinMoz2nAZ6yp3R ro+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779311900; x=1779916700; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=9Tf2Xd147xJ0sNfv/d8vxtKV4pEk11pNA8lNnJlbJZM=; b=KMRRLK/eHOydBV9XktLhHL9oSRPedjVIS2AVP6TwQJZaK3g098xmt7i0GI+Vc+xPPk ccbVgi0PkumY/86k+HzpRIaQAMgIr4qKSGx6FT59MNx5WXu5Dz0INL86ede4WZ1Q/cfo h0NFLUj6QmXP47a2K4neoRRkJPPYMzVjmSKR+9/9lSLs0uwtfmDOJ6VCZESlfWKU3TXF hQA+Znx+cgwp3b5c+rJLKgREaFyqiKRiS+11ur9BrbylMgnXzD/UnvIP6gwVe8nmMKHn aibmwtaI2HYttwfUu+pTNl4+StRivKFj1IycrM67b6gn5Aq/KaEPoLyCejwmHsdTkJ3I rmSw== X-Forwarded-Encrypted: i=1; AFNElJ+thB2UE2laTuwj/X3kNWt6S84gt1c5Lbxl0d7pvW9eZbSlWHebCZqITjSm5ooYJp3FYuGySSD6soR3ED8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8PeI5xjXmdcH/nPD6qRIRpDvAFggfxBIP47VngPzUiGzFjy2c ov7JxugdtZISpPagSTFg5gtT1V+MkTUDrhunau0AkN8WD1ZQfXOCQafuwNjK5U7XHho= X-Gm-Gg: Acq92OGvsvHiBrf+cOvH/pERyCd5luNbdZWjRGh2qNTnCUkHQ4Pkf6f8/PExrRBwI/G JZAcYqY3uyrMLjVJu84eUqoIoQYUSKP8TfAn8GKC6PQolb8dsGin4/R9gUFhs3ylk1Qbysi51KO oGzB5m/m1/iFzEc63hENOzGd9O6W7poZ4qkXK3pnNiOdhYI9NQwqBD26yXgHSrPfCR1MTwgC0NH sztYkvVYdHERrxTLtUq9oUhR6UF32IGW8BeZUUeY+gn4wVxCQHbrNFvVvBpHyZ0SDBGUV6I//Oz 9mlH0N49huJxhUBgCwx2Pp/DfZ+5LePjNpZ34A0xnz2takLDcM4EyFz30kiDGdvy3c2IIe3Ngf6 rKY/ZKBilCWP1zE3PketoOgQi+CotkMG5mnvsUbq2WAZRDaFhGiW0Zu2jmkjFVPp9U00Yy8pzc6 3wbEW5Zy3zP8GPhsCbMY/kce8= X-Received: by 2002:a05:7023:b10:b0:12a:8ea4:252 with SMTP id a92af1059eb24-136327f23d5mr182452c88.4.1779311900270; Wed, 20 May 2026 14:18:20 -0700 (PDT) Received: from localhost ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-134cc33a67csm26481338c88.13.2026.05.20.14.18.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 May 2026 14:18:19 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 20 May 2026 14:18:18 -0700 Message-Id: Cc: , , , "Guenter Roeck" Subject: Re: [PATCH v4 0/3] hwmon: (pmbus/adm1266) add clear_blackbox and powerup_counter debugfs entries From: "Abdurrahman Hussain" To: "Guenter Roeck" , "Abdurrahman Hussain" , "Alexandru Tachici" X-Mailer: aerc 0.21.0 References: <20260516-adm1266-v4-0-1f8df4797258@nexthop.ai> <1783d74e-6acc-40d2-bdff-9bacbb04032c@roeck-us.net> In-Reply-To: <1783d74e-6acc-40d2-bdff-9bacbb04032c@roeck-us.net> On Wed May 20, 2026 at 1:59 PM PDT, Guenter Roeck wrote: > On 5/20/26 12:40, Abdurrahman Hussain wrote: >> On Wed May 20, 2026 at 10:10 AM PDT, Abdurrahman Hussain wrote: >>> On Wed May 20, 2026 at 7:10 AM PDT, Guenter Roeck wrote: >>>> Hi, >>>> >>>> On 5/16/26 18:18, Abdurrahman Hussain wrote: >>>>> This is what remains of the v3 series after Guenter applied patches >>>>> 1/5 (firmware_revision) and 5/5 (GPIO line label) to hwmon-next, and >>>>> asked for patch 4/5 (rtc_class) to be dropped. >>>>> >>>>> Patch 1 adds a write-only clear_blackbox debugfs file. Devices >>>>> configured for single-recording mode (BLACKBOX_CONFIG[0] =3D 0) need >>>>> an explicit clear once the 32-record buffer fills; the documented >>>>> sub-command ({0xFE, 0x00} block-write to 0xDE) wasn't reachable >>>>> from userspace. The patch also acquires pmbus_lock at the >>>>> adm1266_nvmem_read() callback boundary so the memset of >>>>> data->dev_mem, the blackbox refill, and the memcpy to userspace run >>>>> as a single critical section -- the nvmem core does not serialize >>>>> concurrent reg_read calls. >>>>> >>>>> Patch 2 exposes the non-volatile POWERUP_COUNTER (0xE4) via debugfs. >>>>> The same value is embedded in every blackbox record, so the live >>>>> value lets userspace match a captured record back to the boot it >>>>> came from when correlating logs. The block-read is taken under >>>>> pmbus_lock to serialise against any pmbus_core PAGE+register >>>>> sequence on the device. >>>>> >>>>> Patch 3 takes pmbus_lock in adm1266_state_read() (the pre-existing >>>>> sequencer_state debugfs handler) for the same defensive-locking >>>>> reason that motivates the new debugfs files in patches 1 and 2: >>>>> any direct device access from outside pmbus_core should be ordered >>>>> with respect to pmbus_core's own PAGE+register sequences. >>>>> >>>>> Signed-off-by: Abdurrahman Hussain >>>> >>>> The series no longer applies after applying the bug fix series. >>>> Please rebase it on top of the hwmon-next branch of >>>> git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git >>>> and resubmit. >>>> >>>> Sorry for the trouble, and thanks a lot for fixing all the problems >>>> with the driver. >>>> >>>> Guenter >>> >>> Will do, thank you for your support! >>> >>> Abdurrahman >>=20 >> Hi Guenter, >>=20 >> Before I send v5 of the adm1266 series, I'd like to revisit the >> SET_RTC exposure question from your v3 review [1]. >>=20 >> The use case I keep landing on is the one the datasheet itself >> recommends: a userspace agent (chrony hook, systemd-timesyncd >> script, or a small periodic daemon) keeps the chip's seconds >> counter aligned with wall-clock so the value embedded in each >> blackbox record stays correct across long uptimes. The probe- >> time ktime_get_real_seconds() seed (now in hwmon-next) only fixes >> this at boot; the chip's counter drifts after that. >>=20 >> You ruled out rtc_class and called a kernel-side periodic timer >> "a bit excessive", which I agree, it is. That leaves a >> userspace-triggered sync. Two debugfs shapes I'd consider, both under >> pmbus//adm1266/ (alongside the clear_blackbox, >> powerup_counter, and sequencer_state entries v5 already adds): >>=20 >> A. RW since_epoch -- mirrors /sys/class/rtc//since_epoch. >> Read returns the chip's SET_RTC seconds counter, write sets >> it. The read has the useful side benefit of letting >> userspace measure host-vs-chip drift without writing. >>=20 >> B. Write-only set_rtc -- writing anything to the file makes >> the driver read ktime_get_real_seconds() itself and push it >> to SET_RTC. Simpler interface (kernel owns the time >> source; userspace just triggers the sync), no payload to >> parse, no way for userspace to pass in a wrong value. >>=20 > > How about a combination ? read returns the current value, anything > written synchronizes with the kernel rtc. > Going with that for v5. One naming question before I send: - set_rtc -- matches the PMBus command name (SET_RTC =3D 0xDF), but "set" reads as write-only at first glance, which is a bit misleading for an RW file. - since_epoch -- mirrors /sys/class/rtc//since_epoch, but that one is read-only in the RTC subsystem so the dual semantic might surprise users coming from there. - rtc_sync -- describes the write semantic directly, but leaves the read side unnamed. - rtc -- shortest and most neutral; doesn't bias toward either operation. Any preference, or should I just pick? Thanks, Abdurrahman