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 A471FC433F5 for ; Tue, 9 Nov 2021 22:57:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E995610CF for ; Tue, 9 Nov 2021 22:57:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240999AbhKIXAj (ORCPT ); Tue, 9 Nov 2021 18:00:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237674AbhKIXAf (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 09434C04FD86 for ; Tue, 9 Nov 2021 14:54:04 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id t24-20020a252d18000000b005c225ae9e16so962058ybt.15 for ; Tue, 09 Nov 2021 14:54:04 -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=2ZZutKIV0Nj8gy4ay62MqSeceiUy7XXfRiELEuYsEwiLxCk9dezzGKNeM6eMuvdVB8 WQomV6BysYVgDd8Lc45VwXaJtA/BnzwyY9CqNme92vJ/UxmgFm/RPqR98mXCvRrF5oD5 Lxtm94iheHDYz4FKUkXCbrSHw8WuVHpb5PGb7yQgHqTnuqjXTMB6QVGW0i3uT9a//V+1 3FIG/nNo6qNhlDX5dkqQnscgVmv45y9QNoFfoyS1lhsJU++fl2dJZGSwfc7yoHyoPe5F 9yoWE8D9nMKNsR5qwV8KaYkyRcGaq+nV57yEa/AToa6NlfLZwU7BJ7KIHXpPNAvIJ//6 UfNQ== X-Gm-Message-State: AOAM533nq4r7HW4IwCBiNNDXR85wPVMrSGO7dH9/sKsxHW3Uj5cHPDWs B5QICHP6TCxI1MzFBnpA+gXA+U4nfsTpbjlqCIkMMUDsss8ph/R6cg5+8J/nL3yh49xuEjlRNMt 0Jsa6jl/s4P3wthFJJL/nnXK6ffstd5UWuGucKKDWW+GXLWwJ0KOcix2vW1pBGM9+HzwxfJqP 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-kernel@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