From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4FD5C433F5 for ; Tue, 9 Nov 2021 22:57:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84FF261104 for ; Tue, 9 Nov 2021 22:57:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235437AbhKIXAi (ORCPT ); Tue, 9 Nov 2021 18:00:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236673AbhKIXAf (ORCPT ); Tue, 9 Nov 2021 18:00:35 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06C72C04FD85 for ; Tue, 9 Nov 2021 14:54:04 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id b126-20020a251b84000000b005bd8aca71a2so1029996ybb.4 for ; Tue, 09 Nov 2021 14:54:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=fqkBKrDgG+U2J0jLPhfOG5/umxYft29Uz1Bp7bFqlU4=; b=gaizNiw45AQlsLUXXmDt2Z841rK7YK6dEfm5VUXvm3abRCI+G8ZqrXQWuNbZFwSTmh XDzZI4SMXh1Kl1WuBipnZdUMW5smsEdFRI30aJdHi4uxTjC51z/SGOAdP3IDilh5sA6s /sSmu2/cpqoRmeJbNXVj0ei5YxIaGqfnnBf6LzmJqATWgWiIW0Xra422ZhbB2T5p60li 5XlCkM7OAc8IKhtaC9Kb+KTV20K8CJaIJEenVStxz2lj1egMVnF1gWjvufv0elFOFJm6 vQmvqmQak8AO9ZWg2dxaMsYd7YJHpDNagF8ZXUXIP8LumSzCYBbzUn5cgxHU9PfXEk0+ 9RVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=fqkBKrDgG+U2J0jLPhfOG5/umxYft29Uz1Bp7bFqlU4=; b=S2nEJOFdfIq0frRKh5Sd2PpY8ZmQSoJAX7BxQyUg5Okk52vcF67CevNKKz6qZEF6mZ 3MdcGBwNckLSJ50s7rwIeN44LkbefHsHso3ajL10nJxAwxmcnDX1SiBs7mSdr9Gw7rB2 BwNEIHX/va9Er0dYq6MD94kKyKvEfCYHsoXzkDsrfewyA7/LQOxoLjeUIOsKnfkDstRx tW/A+Rps2Jne1xTckO5v9YicrVUtz2AJVtrjyzQmM+SfxIqF+MmI33vN2bPW1K0ghc+e utnnplkqUXOlGhEE+1aRjy8ItC0yjvcUGBnYFYaBU9I0H27X0C/EuYwaCczQRnOB3brh h7Rg== X-Gm-Message-State: AOAM531ysGR5+XT7lAvLvxq9eLauHahk1w82x9YhNX/5J7QQU61uu9Td kjjtU36Yo2Oa2f48BY1etN0YaY2X13q8 X-Google-Smtp-Source: ABdhPJzNKPj7oPovvEeYQf8vpEbvDToEAPKuadIbnxVFDOySdOXin+j0m8TstBdNk2fD9endANDJ4D0MzBGV X-Received: from suichen.svl.corp.google.com ([2620:15c:2c5:13:7559:12f5:de29:c918]) (user=suichen job=sendgmr) by 2002:a25:e6c5:: with SMTP id d188mr12102876ybh.217.1636498443089; Tue, 09 Nov 2021 14:54:03 -0800 (PST) Date: Tue, 9 Nov 2021 14:53:19 -0800 Message-Id: <20211109225321.618688-1-suichen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.0.rc0.344.g81b53c2807-goog Subject: [RFC Patch Resend 0/2] I2C statistics as sysfs attributes From: Sui Chen To: linux-kernel@vger.kernel.org Cc: Sui Chen , OpenBMC Mailing List , linux-i2c , Joel Stanley , Andrew Jeffery , Tali Perry , Benjamin Fair , Josh Lehan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add I2C statistics such as Bus Error counts and NACK counts as sysfs attributes. I2C statistics such as bus error counts and NACK counts, are implemented in many I2C controllers. Some drivers already populate the counters in debugfs. Having those statistics in sysfs can enable for a unified definition across various I2C drivers, make the statistics more ABI-stable. Overall the patch works in the following way: 1) A sysfs directory for I2C statistics is created for an i2c_adapter. 2) Each specific I2C driver can optionally instantiate each of the statistics individually. Test Process: 1. Clone the OpenBMC repository 2. `devtool modify`and apply patch to the linux-nuvoton recipe 3. Build image for quanta-gsj 4. Build QEMU 5. Run the image-bmc image in QEMU Results: root@gsj:/sys/class/i2c-adapter/i2c-1/stats# ls ber_cnt i2c_speed nack_cnt rec_fail_cnt rec_succ_cnt timeout_cnt root@gsj:/sys/class/i2c-adapter/i2c-1/stats# cat * 0 100000 0 0 0 0 Sui Chen (2): i2c debug counters as sysfs attributes add npcm7xx debug counters as sysfs attributes drivers/i2c/busses/i2c-npcm7xx.c | 8 +++ drivers/i2c/i2c-core-base.c | 2 + drivers/i2c/i2c-dev.c | 98 ++++++++++++++++++++++++++++++++ include/linux/i2c.h | 26 +++++++++ 4 files changed, 134 insertions(+) (Previously sent to linux-i2c, resending to linux-kernel with CCed correspondents) CC: OpenBMC Mailing List CC: linux-i2c CC: linux-kernel CC: Joel Stanley CC: Andrew Jeffery CC: Tali Perry CC: Benjamin Fair CC: Josh Lehan -- 2.34.0.rc0.344.g81b53c2807-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF578C433F5 for ; Tue, 9 Nov 2021 22:54:49 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25458610C8 for ; Tue, 9 Nov 2021 22:54:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 25458610C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Hpjwl3705z2yPM for ; Wed, 10 Nov 2021 09:54:47 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=gaizNiw4; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--suichen.bounces.google.com (client-ip=2607:f8b0:4864:20::b4a; helo=mail-yb1-xb4a.google.com; envelope-from=3c_ykyqckb0iwymglirksskpi.gsqstirfqgpmwxw.s3pefw.svk@flex--suichen.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=gaizNiw4; dkim-atps=neutral Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Hpjw22ks2z2xgb for ; Wed, 10 Nov 2021 09:54:08 +1100 (AEDT) Received: by mail-yb1-xb4a.google.com with SMTP id w132-20020a25c78a000000b005c27f083240so937304ybe.16 for ; Tue, 09 Nov 2021 14:54:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=fqkBKrDgG+U2J0jLPhfOG5/umxYft29Uz1Bp7bFqlU4=; b=gaizNiw45AQlsLUXXmDt2Z841rK7YK6dEfm5VUXvm3abRCI+G8ZqrXQWuNbZFwSTmh XDzZI4SMXh1Kl1WuBipnZdUMW5smsEdFRI30aJdHi4uxTjC51z/SGOAdP3IDilh5sA6s /sSmu2/cpqoRmeJbNXVj0ei5YxIaGqfnnBf6LzmJqATWgWiIW0Xra422ZhbB2T5p60li 5XlCkM7OAc8IKhtaC9Kb+KTV20K8CJaIJEenVStxz2lj1egMVnF1gWjvufv0elFOFJm6 vQmvqmQak8AO9ZWg2dxaMsYd7YJHpDNagF8ZXUXIP8LumSzCYBbzUn5cgxHU9PfXEk0+ 9RVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=fqkBKrDgG+U2J0jLPhfOG5/umxYft29Uz1Bp7bFqlU4=; b=xN62h5hWX0j23aAL4Xl6jkvrvSUC/bjCg8hktYN5AfFTsXcu+vn3PLtolbagTDjkAZ Xucye4CjWGPNJJc7JYxlR8rsorLnL+sTx2lEOIZ02ILNm61JPO6+rTK7vH6LtRXKIFaU mukWfBLvqc5IXIH26h5TjEyK0H0CPfwXA6pUk/psiA5+eQQb79pEsO5I3aE4kKV8ZsFm giUVti2h+Xu2TgUy3F1QIKn88ZxOeorlE6sY5NoIrxjO10pyEKJQh8rQGzUBMoh2EPXO 4n1p5prfVonEs8iJbDlQxp2fNC/3lEbwXdTtJJo7M69KlrXYjnWP+NnoRqXb3WBNbXh/ u/JQ== X-Gm-Message-State: AOAM530enqGE1DkdfiqNuxcTW3rvJDfmLjZATmVkciw1FIcOwp5wQG5r cxfv+7Sa6imcwvnKih2LXUUBZ5WWnsE4 X-Google-Smtp-Source: ABdhPJzNKPj7oPovvEeYQf8vpEbvDToEAPKuadIbnxVFDOySdOXin+j0m8TstBdNk2fD9endANDJ4D0MzBGV X-Received: from suichen.svl.corp.google.com ([2620:15c:2c5:13:7559:12f5:de29:c918]) (user=suichen job=sendgmr) by 2002:a25:e6c5:: with SMTP id d188mr12102876ybh.217.1636498443089; Tue, 09 Nov 2021 14:54:03 -0800 (PST) Date: Tue, 9 Nov 2021 14:53:19 -0800 Message-Id: <20211109225321.618688-1-suichen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.0.rc0.344.g81b53c2807-goog Subject: [RFC Patch Resend 0/2] I2C statistics as sysfs attributes From: Sui Chen To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Fair , Andrew Jeffery , OpenBMC Mailing List , Tali Perry , Josh Lehan , Sui Chen , linux-i2c Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" Add I2C statistics such as Bus Error counts and NACK counts as sysfs attributes. I2C statistics such as bus error counts and NACK counts, are implemented in many I2C controllers. Some drivers already populate the counters in debugfs. Having those statistics in sysfs can enable for a unified definition across various I2C drivers, make the statistics more ABI-stable. Overall the patch works in the following way: 1) A sysfs directory for I2C statistics is created for an i2c_adapter. 2) Each specific I2C driver can optionally instantiate each of the statistics individually. Test Process: 1. Clone the OpenBMC repository 2. `devtool modify`and apply patch to the linux-nuvoton recipe 3. Build image for quanta-gsj 4. Build QEMU 5. Run the image-bmc image in QEMU Results: root@gsj:/sys/class/i2c-adapter/i2c-1/stats# ls ber_cnt i2c_speed nack_cnt rec_fail_cnt rec_succ_cnt timeout_cnt root@gsj:/sys/class/i2c-adapter/i2c-1/stats# cat * 0 100000 0 0 0 0 Sui Chen (2): i2c debug counters as sysfs attributes add npcm7xx debug counters as sysfs attributes drivers/i2c/busses/i2c-npcm7xx.c | 8 +++ drivers/i2c/i2c-core-base.c | 2 + drivers/i2c/i2c-dev.c | 98 ++++++++++++++++++++++++++++++++ include/linux/i2c.h | 26 +++++++++ 4 files changed, 134 insertions(+) (Previously sent to linux-i2c, resending to linux-kernel with CCed correspondents) CC: OpenBMC Mailing List CC: linux-i2c CC: linux-kernel CC: Joel Stanley CC: Andrew Jeffery CC: Tali Perry CC: Benjamin Fair CC: Josh Lehan -- 2.34.0.rc0.344.g81b53c2807-goog