From nobody Mon May 25 07:36:19 2026 Received: from mail-dy1-f177.google.com (mail-dy1-f177.google.com [74.125.82.177]) (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 3983828725B for ; Sun, 17 May 2026 01:18:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778980706; cv=none; b=aZvpS08DTJzuw4wytCJI+o0jlZHKoTmDxbwvB++YGWsRkvVJjQv8owuVs53qWxLBHu0Sq2OIoNu2iolOcJaYlI3FhGcYCUmiNuhnfvZIGNNmELPHZMAez3Hlf4mN32Tcr3a94Y1tFZ2s/Ystd97slQFhAagJc9RxVp9yCskxStc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778980706; c=relaxed/simple; bh=aqjK7wL4qG4YIi+HNyz219JOuZW698caEqsx9hyaQiY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TpHt67S357GZxMKjXUBRPJ3F1m+8feA3eJnPPk2jQnug7BvyYRKbQ0ET/Nm+FW7U5E7/8160GG07KVHCXO7kAh7+IIFkR7Xyk/Sxqf7wwit9rVaoFGIVesuuQ6eih27ddb9bH26LkbUxIbWa7+AzNGB7ppRjrIdW8Ohoc7dlefw= 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=dOySqmcH; arc=none smtp.client-ip=74.125.82.177 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="dOySqmcH" Received: by mail-dy1-f177.google.com with SMTP id 5a478bee46e88-2f7020a928eso1471341eec.1 for ; Sat, 16 May 2026 18:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1778980704; x=1779585504; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=w9ROmFxNAGb/pGdvNxezxVPGIOiaMGXemePEILBHCHA=; b=dOySqmcHz/8OPDnkBFmPCe9uS0axhIv6hfXTdisvfP5JNyUtJDAHDKCuTxeETa5kcL q7B2ajUh00vj+ksffvIEVsJmtbQjlpRq9QInID/5BgEr1D1D1ndYTXbVtIJw0gduAuSD 2xvwXSls4Rv1YhiLdjSFlRgzzeKHLWumKCNHfZFCHipkaDllgELytHjkfu6HDy2EqtZm ficwIzeAVmbLskPzCouKkiCMkEpfeiHa1xvbcwO0tQaIMzDE0S2/NXBnpDdYGo8Vc6tM VpRnYa+u0xautoLZiftC+fG7bK1zTkasBBYcVEzA1yShQlA+/fV8TCtqqmimswKGxtyf vVpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778980704; x=1779585504; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=w9ROmFxNAGb/pGdvNxezxVPGIOiaMGXemePEILBHCHA=; b=aD+/Dxo8tgDYewA5PbPQtKR+3uLvfA2x5nMu6HVbGDuQUhN9GPNfuNsTSYOGGxlu9a q/nQQ3DwdNWq9zetmRrQBGR5AsI/ci9GQWH2AWjdQvSLD+vr7Xd1lY3XSkJGSG0+Y0xg Yrxsthx6q+at3k4iA7c+UdSc1xMuh1+bCXdhrltb8zzzZMO44ntKnyapfrQSlbzOtex+ XQByQOysHfCDhoFNpn/sLj8TC5ZJXcHW68rtOP4Qa7LsrPNo7yjOB4nsXFQEHadrZW37 cPoFhjckhdob4T6OXqdhllgWF5l3vePu8OCane4G7G3+C/cZumErcFWCNI+nTamb1wY7 ljww== X-Forwarded-Encrypted: i=1; AFNElJ+7pLVcGdRbWbCxkdVnoMnyOwPG+h7kAtgR8w0z7ureK/ly9fKNzVE7f3sAZ+lDW2h6m4Uy/B12mhFmrmk=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0IPsDptVP25ByIYbiX+QJAPKW93E7OyRoTGa3h++DaxCSilOE dhoJMleyEH3ToA8dw1VAksXdFPEESpPtl2nK6KUymuhGswVSRlY99mFgD4BnX2vbLpM63f4fPEK FcMLzR4k= X-Gm-Gg: Acq92OH0eH7hTO8lUvcKHcqCmajxwn0ECkwBSPgpmzL9/4gXp/11GU8eACPDDR3weHK ztolx67fsJ+TADDqRiF//3p5iHxGlvIcnvI1aFFXvzDgBp56ip0ersGhNGwGn/CfcRf6bCieAeP HSWd0sKmB3oTbJFI17aLM5D+gaW2vBX6NRqydwSPZ048BRS18oZsMlycFzrPhHkMaM1Cozy5HqE b0n8Dc3Zp8IZ+h3rBjdJPFGU/YxHZdLGUEfkfUzAwx9Xa1qp9kPAXLUqV1hOEyDHxlBO7dmW9ot zXRP0ZZQNZABV4t+aGhaWrYh0xdjsYwfCrjDtTv24ziZVG10FXBpTIYf11vVN88yAvbj8mj6yBR vQk9Cs73M1T+ZmisSkrxhtxbzjEo9IrhZA5PtEBZ2gJLJrR/IEtqhYJE6+i1wPWNEoBjZaCEWmS mvGGRNPpSA0GHNIyU6xIGSvxNiAw== X-Received: by 2002:a05:7301:644b:b0:2f0:4268:bc42 with SMTP id 5a478bee46e88-3039869954amr4386878eec.25.1778980703955; Sat, 16 May 2026 18:18:23 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-302973bbd50sm10582179eec.20.2026.05.16.18.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 18:18:23 -0700 (PDT) From: Abdurrahman Hussain Date: Sat, 16 May 2026 18:18:19 -0700 Subject: [PATCH v4 1/3] hwmon: (pmbus/adm1266) add clear_blackbox debugfs entry Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260516-adm1266-v4-1-1f8df4797258@nexthop.ai> References: <20260516-adm1266-v4-0-1f8df4797258@nexthop.ai> In-Reply-To: <20260516-adm1266-v4-0-1f8df4797258@nexthop.ai> To: Guenter Roeck , Alexandru Tachici Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Abdurrahman Hussain X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778980702; l=4654; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=aqjK7wL4qG4YIi+HNyz219JOuZW698caEqsx9hyaQiY=; b=BLUJi7FiSAnjHBV3NXgVBmqxWfba4gFTCSk2aZpf8Hc5FsP4zcRUn2G9ie6yMup6wdWF/Vskh 6pjLW6YY8oYAkOwEP8JN0kJCNvy8xMRtaq6Eb5H/VcxBP+lm7Ewmdzx X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= The ADM1266 blackbox can be configured in two recording modes via BLACKBOX_CONFIG[0]: cyclic, where the device overwrites the oldest record once the 32-record buffer fills, and single, where it stops recording until the buffer is cleared. Deployments that need to preserve the full record history across multiple fault episodes typically run in single mode and need a way to clear the buffer after the records have been collected. Expose a write-only debugfs file alongside sequencer_state. Writing any data to it issues the documented clear-blackbox sub-command: a 2-byte block-write to READ_BLACKBOX (0xDE) with payload {0xFE, 0x00} (datasheet Rev. D). The clear is taken under pmbus_lock because READ_BLACKBOX is also used by adm1266_nvmem_read_blackbox() to walk records one at a time; without the lock the clear could interleave mid-iteration and corrupt the read sequence. Also acquire pmbus_lock in adm1266_nvmem_read() so the memset of data->dev_mem, the blackbox refill, and the memcpy out to userspace run as a single critical section. The nvmem core does not serialize concurrent reg_read calls, so two concurrent reads of the nvmem device could otherwise race the memset against the memcpy and copy garbage to userspace. Signed-off-by: Abdurrahman Hussain --- drivers/hwmon/pmbus/adm1266.c | 47 +++++++++++++++++++++++++++++++++++++--= ---- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c index d90f8f80be8e..9f4709bc85af 100644 --- a/drivers/hwmon/pmbus/adm1266.c +++ b/drivers/hwmon/pmbus/adm1266.c @@ -331,6 +331,39 @@ static int adm1266_state_read(struct seq_file *s, void= *pdata) return 0; } =20 +/* + * Clearing the blackbox is required when the device is configured in + * single-recording mode (BLACKBOX_CONFIG[0] =3D 0): once the 32-record + * buffer is full the device stops recording until cleared. + * + * The clear is issued as a 2-byte block-write to READ_BLACKBOX with + * payload {0xFE, 0x00} per the datasheet. READ_BLACKBOX is also used + * by adm1266_nvmem_read_blackbox() to walk records one at a time; + * both paths run under pmbus_lock so the clear cannot interleave + * mid-iteration and corrupt the read sequence. + */ +static ssize_t adm1266_clear_blackbox_write(struct file *file, const char = __user *ubuf, + size_t count, loff_t *ppos) +{ + struct i2c_client *client =3D file->private_data; + u8 payload[2] =3D { 0xFE, 0x00 }; + int ret; + + guard(pmbus_lock)(client); + ret =3D i2c_smbus_write_block_data(client, ADM1266_READ_BLACKBOX, + sizeof(payload), payload); + if (ret < 0) + return ret; + + return count; +} + +static const struct file_operations adm1266_clear_blackbox_fops =3D { + .owner =3D THIS_MODULE, + .open =3D simple_open, + .write =3D adm1266_clear_blackbox_write, + .llseek =3D noop_llseek, +}; static void adm1266_init_debugfs(struct adm1266_data *data) { struct dentry *root; @@ -343,6 +376,8 @@ static void adm1266_init_debugfs(struct adm1266_data *d= ata) =20 debugfs_create_devm_seqfile(&data->client->dev, "sequencer_state", data->= debugfs_dir, adm1266_state_read); + debugfs_create_file("clear_blackbox", 0200, data->debugfs_dir, data->clie= nt, + &adm1266_clear_blackbox_fops); } =20 static int adm1266_nvmem_read_blackbox(struct adm1266_data *data, u8 *read= _buff) @@ -355,7 +390,6 @@ static int adm1266_nvmem_read_blackbox(struct adm1266_d= ata *data, u8 *read_buff) ret =3D i2c_smbus_read_block_data(data->client, ADM1266_BLACKBOX_INFO, bu= f); if (ret < 0) return ret; - if (ret !=3D 4) return -EIO; =20 @@ -365,7 +399,6 @@ static int adm1266_nvmem_read_blackbox(struct adm1266_d= ata *data, u8 *read_buff) ret =3D adm1266_pmbus_block_xfer(data, ADM1266_READ_BLACKBOX, 1, &index,= read_buff); if (ret < 0) return ret; - if (ret !=3D ADM1266_BLACKBOX_SIZE) return -EIO; =20 @@ -383,6 +416,8 @@ static int adm1266_nvmem_read(void *priv, unsigned int = offset, void *val, size_t if (offset + bytes > data->nvmem_config.size) return -EINVAL; =20 + guard(pmbus_lock)(data->client); + if (offset =3D=3D 0) { memset(data->dev_mem, 0, data->nvmem_config.size); =20 @@ -470,14 +505,14 @@ static int adm1266_probe(struct i2c_client *client) if (ret < 0) return ret; =20 - ret =3D adm1266_config_nvmem(data); - if (ret < 0) - return ret; - ret =3D pmbus_do_probe(client, &data->info); if (ret) return ret; =20 + ret =3D adm1266_config_nvmem(data); + if (ret < 0) + return ret; + adm1266_init_debugfs(data); =20 return 0; --=20 2.53.0 From nobody Mon May 25 07:36:19 2026 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (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 E2DC329D288 for ; Sun, 17 May 2026 01:18:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778980707; cv=none; b=R9ArKc2xS+CAlxleGOZRkJf+vuopjKd1p/8RDRIqe2EXhLK5iNWjc2VguMZQhZkIC16xbfEaG4qOY9kde7AOh6H49Hi6viQwOWs+h2unUyqF3d4zMDmB4UZxy702Iw7ZdCgqvnfCN7Hmv+13ujadt3HWmuG7I8CYxOZ1XmHyYKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778980707; c=relaxed/simple; bh=GfZ4v/mNpI+1fGteLD86m+DRc8AuH5keWfQhto4lX6U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F8nv3+CkZ4M9N78/Ru/IAGiuNMc9qqBV5WhRQQ4WGUR5uNgbpmsLHFMbrIr0aUjUDgTtY+DWxFe4BHZwsdRnoXvH0Jqc6Z+HK2RB6L95Rwo3EnyEAOyEuy/Z5HmoLolLYGTfE+svRDFzeaEsJ8pbmqkxp8KPrfZAg79vXlpcJ90= 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=ABADUWkY; arc=none smtp.client-ip=74.125.82.171 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="ABADUWkY" Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-2f0d3e07e30so5126879eec.0 for ; Sat, 16 May 2026 18:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1778980705; x=1779585505; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HIjV6KloXt2Yl7YHLO/Gzukpo75oolPgwlt5A0S4fZY=; b=ABADUWkYW051Lw+SRld0DclvzL4Vi3u+M4cYD1epyvRz1k6/I2Nm/ZkV3IxMMmWJuk YR+3ppBpzjy6fw0NSlU/XjIjUPlT2Ku5CG5+VfNRHok6RYMvk3WVia+DDSUOWQnO/yxU jwsamQrvzgGRNTrlTdVp1eiSyBiz/ngMZ6jBBDdHZabP+yKxcy/MUpGJq2iSjfrOWHav 4QO4pqxYlB1yGzNLCFjEl4NcoDFOsd3LSRBgcU0i9nClCULxLGarnJF4N/81KC6p9qlZ rn1p/zi0Jcwb1NUouGhDM6QFRQwm9so7/AC2B+YI+3NjKm0iMI4+ey2+6pcJkMfj9aWK qk5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778980705; x=1779585505; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=HIjV6KloXt2Yl7YHLO/Gzukpo75oolPgwlt5A0S4fZY=; b=GOeF3FTiL/Ek3qd+4xy1xy/HpLGngZAGpbeht/P+/5wGWHDTNBnDi5wQpOFgH4vRZp lRMpzo1aSSymLKwor5a1wK8oh9X+RcrLb/BUyPK+MOTOvW1wIscQbTxkgVDieb1lCa+I UjxLvnKMgK1BjBbzvSJDr8LTXkizLSoM/Ts7hGe8W+wjtkhzUVgEzRk3WB7/VWx8b5Xg r6+lcsF5nblyKBrGYeWhxa7cY3cJhIxRn2EuDbTGH+BXc2yeNDzmDVMTM5EWQBSYfpou TyfWLalFHCVh/p6dXFAGQREBsnqGQ3N1REgva+B3ffX3GjpJnjP1aV8duJhgyZiMMVkK 2bBQ== X-Forwarded-Encrypted: i=1; AFNElJ+R0wG3zZJWrkdGGUJmqNqixfn7o2kMSj3+jiQbt3taEKgWWxQGTSiCNCbGOnZ9WEGDwxuboACPK9GOJF0=@vger.kernel.org X-Gm-Message-State: AOJu0YzceHUHZXDv4Ck6MG5lzgstKjtLTY6HXMFd9M2wk/hcMnlU2P0h jiVCoxyDsRMgXnrJCEtZemCRVPQpmRv/fOAr8ij/SX+D2Qa6XKbhfCt0+tyiLxvNcit23qvXLY8 VBvhAgk4= X-Gm-Gg: Acq92OERnKYMW5wmTm8kmvkiTRTpjRFLa9fx/A3hTf/x2+4Z8y0oVcLi3T1Q3SQsbOE fOFtlrh+yZ5zn6mbz/MovTHW9ESmXjyU0IZVmPn9iMChdL+8l526m0lnVQO4oFFjD1OqRIn5SiC JBnmTt6kQT23bvUF+PDUEBWW3+wu/nFwNZog//by8fgbhRMM8WPOrkE4fo9djmmuh4RjVdpM4bW JyY9dgx0TKrb4bm8XhTXi9w4e1b6r7e82d8uFX8MgYxRiJ7ltD0MQ5u3tPC4iqXJh5ZnuWeEiPo JgEbApM8mjCfxF/4ESR76P29GcUC6Sil2LU1gIfyzJObfvZcvcj6S38CcHEX2ScfKOL851xzG4L xgxvTLVGFoU1h49BM+N71jreudsdVzeqlRm1fU+tzNkkB8GKnGcGyfQbRwwNN8R2QXUdLoltVaY LSC3iHlXoti2izeBgE/ay1QK42lSDTTVRP6jKBCcSE0Q3Hd34= X-Received: by 2002:a05:7301:678d:b0:2ed:e15:c925 with SMTP id 5a478bee46e88-303986be114mr4750520eec.33.1778980704636; Sat, 16 May 2026 18:18:24 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-302973bbd50sm10582179eec.20.2026.05.16.18.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 18:18:24 -0700 (PDT) From: Abdurrahman Hussain Date: Sat, 16 May 2026 18:18:20 -0700 Subject: [PATCH v4 2/3] hwmon: (pmbus/adm1266) add powerup_counter debugfs entry Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260516-adm1266-v4-2-1f8df4797258@nexthop.ai> References: <20260516-adm1266-v4-0-1f8df4797258@nexthop.ai> In-Reply-To: <20260516-adm1266-v4-0-1f8df4797258@nexthop.ai> To: Guenter Roeck , Alexandru Tachici Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Abdurrahman Hussain X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778980702; l=3012; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=GfZ4v/mNpI+1fGteLD86m+DRc8AuH5keWfQhto4lX6U=; b=Ng+E4eEqA7hk5dkWc9EW8BG9VXfHi4OAZttlGMfkQZgGwc8XCL8xncpIiLqDAz55G01bioXJF EOQH6l4cODoA1z6lprWviixsGMq2bwVcFwPQMTjciGb5n26r/rvZDLs X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= The ADM1266 maintains a 16-bit non-volatile POWERUP_COUNTER register (0xE4, datasheet Rev. D, Table 93) that increments on every power cycle and cannot be reset by the host. Each blackbox record already embeds the counter at record time, so the standalone live value is primarily useful for matching a captured record back to the boot it came from when correlating logs. Expose it as a read-only debugfs file alongside sequencer_state. The block-read returns two payload bytes in little-endian order. Take pmbus_lock around the block-read so the access serialises with any pmbus_core sequence that sets PAGE on the device. Without it, a PAGE write from another thread could interleave between a PAGE set and a paged read elsewhere in the driver and corrupt either side's view of the device state machine. Signed-off-by: Abdurrahman Hussain --- drivers/hwmon/pmbus/adm1266.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c index 9f4709bc85af..2edf3a424679 100644 --- a/drivers/hwmon/pmbus/adm1266.c +++ b/drivers/hwmon/pmbus/adm1266.c @@ -27,6 +27,7 @@ #define ADM1266_READ_BLACKBOX 0xDE #define ADM1266_SET_RTC 0xDF #define ADM1266_GPIO_CONFIG 0xE1 +#define ADM1266_POWERUP_COUNTER 0xE4 #define ADM1266_BLACKBOX_INFO 0xE6 #define ADM1266_PDIO_STATUS 0xE9 #define ADM1266_GPIO_STATUS 0xEA @@ -331,6 +332,32 @@ static int adm1266_state_read(struct seq_file *s, void= *pdata) return 0; } =20 +/* + * POWERUP_COUNTER (0xE4) is a 2-byte little-endian non-volatile counter + * that increments on every device power cycle (datasheet Rev. D, Table + * 93). It saturates at 65535 and cannot be reset by the host. Each + * blackbox record embeds the counter value at record time, so this live + * read is mainly useful for matching a record back to its boot. + */ +static int adm1266_powerup_counter_read(struct seq_file *s, void *pdata) +{ + struct device *dev =3D s->private; + struct i2c_client *client =3D to_i2c_client(dev); + u8 buf[I2C_SMBUS_BLOCK_MAX]; + int ret; + + guard(pmbus_lock)(client); + ret =3D i2c_smbus_read_block_data(client, ADM1266_POWERUP_COUNTER, buf); + if (ret < 0) + return ret; + if (ret !=3D 2) + return -EIO; + + seq_printf(s, "%u\n", buf[0] | (buf[1] << 8)); + + return 0; +} + /* * Clearing the blackbox is required when the device is configured in * single-recording mode (BLACKBOX_CONFIG[0] =3D 0): once the 32-record @@ -376,6 +403,8 @@ static void adm1266_init_debugfs(struct adm1266_data *d= ata) =20 debugfs_create_devm_seqfile(&data->client->dev, "sequencer_state", data->= debugfs_dir, adm1266_state_read); + debugfs_create_devm_seqfile(&data->client->dev, "powerup_counter", data->= debugfs_dir, + adm1266_powerup_counter_read); debugfs_create_file("clear_blackbox", 0200, data->debugfs_dir, data->clie= nt, &adm1266_clear_blackbox_fops); } --=20 2.53.0 From nobody Mon May 25 07:36:19 2026 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (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 8673929B795 for ; Sun, 17 May 2026 01:18:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778980708; cv=none; b=rMpAYrFvwdZKge7d8vQQb2BpWNhhBqqO5Jf6QkZp3pQ5zkrqOrgC5TqfOUK2bOE/XvHvmEOIadZQArjlB4xvV9jpvclkRRXecvIyBL8xjvfHVEt1VJbk95B1zYmULeSzN68WgJRwLdTge2zhTMkS3HQDo2+xyVZQvypU3NkAjrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778980708; c=relaxed/simple; bh=1oaVCYFu+Z3wn0PGr8YB2H02b7P7H8B/ZEdQDxK0+R8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WsGAbXbea345fU6lWV1IL+GuR7F0fnhQPA6kAT97XZLZ9fK4xHSbD7/1LYV1SmFSGcPtEHwYF0l+22OLGRgK0ph8hvKX3owLC/LhG0iOqpaYo0Kd6YsnC9eCGFWy0wZv0G+VlbYFpf6wjUr3TofJQaQoYcDijjxlEuRSk5XyBc8= 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=TcCiQumS; arc=none smtp.client-ip=74.125.82.171 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="TcCiQumS" Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-2f0d3e07e30so5126900eec.0 for ; Sat, 16 May 2026 18:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1778980705; x=1779585505; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IYSwPCVBiY867WtlOZHd6+dxA6JQuid7JW7mJwnbMfw=; b=TcCiQumS3JMRRQgYEl1wrq40MN8Mn/59wxYrvpKT23k3L8VjEZwEK0xFbB33BXhTHi O0AQPPoXg7//BN//7gMlXCtB4khoVY2U9zccNFhlFyU/zM0h0UUcKzub85EGF014sOpX ZXzlwsbIlfaW7NnMFg+lIIQpoXopYI2/UJaSS81WpBN5BmZ+nPRx5bdXhm06o4ar1FVw lpCnLG0lQbgAA5BIwQg2ZbDjO/J2uAaDZbqbLtbiaY/CB8bE+saqSozVf75uNqpqVbY4 KNpFaIFrZER7QxIlmijRq/jQ0GoSyc2M0+TSQ0FugFu+PktMjcTS2vrudRl6YbZpfQzr Qjmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778980705; x=1779585505; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=IYSwPCVBiY867WtlOZHd6+dxA6JQuid7JW7mJwnbMfw=; b=YvgWsysDkz9Ed3XOfleqav92myV77dv5DAN1YFZ0FTqzOb0LbFxImwVZ3/uvUXLoTJ YnbtgTnI9QXxh1/Wu+VKbp8xaQQSeUBQkf3PilbyBe4pFxWcyrWRu0767VLtlM9CBsa7 oF6R1d3mFtj9ba6ZlgJWa4fKhexEhUfFxUyWPJvp/BiU+OdpNHBq42B2o54eN0nmkIB4 dhLfxBo0svWelzjHHEIMA81cnaqV7Ylfb5qkZp9wYZcSw/6/K11bf5SC4FYsfHrBF/4b /9UPkGYfKjzSDDlno9gAjX4Si2Bk7GxHqpnif47iyX0xjTaT6Unoi4ni/8L+3VqQqpum I9rA== X-Forwarded-Encrypted: i=1; AFNElJ8R6yUw92ERKPrNeBMoP5HYNC/NxO5kxYuous3MsbfvbUOAcOGrsHImrQ6gImh2wcsMGRxkxe8Rk2/AOVk=@vger.kernel.org X-Gm-Message-State: AOJu0YyD4kHOwBdSmq+ewMgOtOV0e4HN/leIeZcsvRGuaoyY5j7aNksy qE3b7Y72ToTa+5V9eLiWTpVJbcQAXzsGLvn8yJxYWo78eWJO5I9FX9iibJ5O9SMY0KDcS/oU2tH rpBGNYqk= X-Gm-Gg: Acq92OGZyCF5Db4hmh/woBGrCzzACgBKSf/Lqd+fAaflRXhCC5X8aeLtVTBdazoh2UP 7BAieKFffQ1rDYvcI/RFfIsbzTaUsDoXu8WN0Fjjlo9zLmGapkuEwb+QA/eJQ/k95LrC7s5zVJw JjGk58psNlDOEFk9qkGkt9D9SMhaBSLNepAm3KNlxvbJlfhWqjVayemGw3xj2qAXqFCwZaVn8Cu UJ2fZCces9QZC5ZkjRUrxSFb74gRyYRAmeK+aaaTfY6zq8/eAQcz1cPfLDHVwC7Wyl4TASUp+n3 yp6k0dsINgqlT1XBWNX5k8ZJzNNKH/BBqpwWc60JhbL/vqiqwLWu78t9Vvrtld/8SktxwhvP3+6 jvM08YlzJ0SsV91N4/pxyucB+QheGAbBRQnMBH0Lr6LmEDELUsGh/r20p9DUZrKoUM9bZl1xe2d mv49aqWZeONFhCdujLTmnh61jYOQ== X-Received: by 2002:a05:7300:e430:b0:2f1:3aa8:f2c with SMTP id 5a478bee46e88-303981914bdmr4574268eec.4.1778980705368; Sat, 16 May 2026 18:18:25 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-302973bbd50sm10582179eec.20.2026.05.16.18.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 18:18:24 -0700 (PDT) From: Abdurrahman Hussain Date: Sat, 16 May 2026 18:18:21 -0700 Subject: [PATCH v4 3/3] hwmon: (pmbus/adm1266) serialize sequencer_state debugfs read with pmbus_lock Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260516-adm1266-v4-3-1f8df4797258@nexthop.ai> References: <20260516-adm1266-v4-0-1f8df4797258@nexthop.ai> In-Reply-To: <20260516-adm1266-v4-0-1f8df4797258@nexthop.ai> To: Guenter Roeck , Alexandru Tachici Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Abdurrahman Hussain , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778980702; l=1541; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=1oaVCYFu+Z3wn0PGr8YB2H02b7P7H8B/ZEdQDxK0+R8=; b=gw9OQFjQpIlwlV53+0l9EP5duOSRP6WpWgKJG5fonuIRM7fKGg7xEStTvs8VETKX9jmMk7tma /HbqVdVvgKqBdKEdbdmRGcXFTZWv+OJpKNiHYf/5ysVroM3jYn7OGr6 X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= adm1266_state_read() backs the sequencer_state debugfs entry and issues an i2c_smbus_read_word_data(client, ADM1266_READ_STATE) against the device without taking pmbus_lock. The pmbus_core framework holds pmbus_lock around its own multi-transaction sequences (notably the "set PAGE, then read paged register" pattern used by hwmon attributes), so an unlocked debugfs reader can land between a PAGE write and the subsequent paged read in another thread. READ_STATE itself is not paged, so it cannot corrupt the PAGE register in flight, but the same defensive serialisation that applies to the GPIO accessors applies here: any direct device access from outside pmbus_core should be ordered with respect to pmbus_core's own. Take pmbus_lock at the top of adm1266_state_read() via the scope-based guard(). Fixes: ed1ff457e187 ("hwmon: (pmbus/adm1266) add debugfs for states") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain --- drivers/hwmon/pmbus/adm1266.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c index 2edf3a424679..1425371bf1be 100644 --- a/drivers/hwmon/pmbus/adm1266.c +++ b/drivers/hwmon/pmbus/adm1266.c @@ -323,6 +323,7 @@ static int adm1266_state_read(struct seq_file *s, void = *pdata) struct i2c_client *client =3D to_i2c_client(dev); int ret; =20 + guard(pmbus_lock)(client); ret =3D i2c_smbus_read_word_data(client, ADM1266_READ_STATE); if (ret < 0) return ret; --=20 2.53.0