From patchwork Tue May 17 10:05:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Chen X-Patchwork-Id: 574704 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8297FC4332F for ; Tue, 17 May 2022 10:07:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238916AbiEQKHw (ORCPT ); Tue, 17 May 2022 06:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231985AbiEQKFo (ORCPT ); Tue, 17 May 2022 06:05:44 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE0FB49F22 for ; Tue, 17 May 2022 03:05:21 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2fecfc7a95aso68182837b3.22 for ; Tue, 17 May 2022 03:05:21 -0700 (PDT) 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=ZA9V5lO/+F+bF8jz1FqVjCsKgJDekjpTcf5RC67Rb+U=; b=CN+dHXm2PBRqvy1rf8fgS0o1jp5PYo7NivTVKQ/nKjhnlxSy7HON46mSOSXnbxnGt0 0sM5TU3u1zBA21392OldZVr96LXY6KYit/jNYjk5EXR2CKoahlGMahwQ3FJUVseXyfI9 cjBk1AWdrStlRBMUoPYESDY747UFkaFerpdGd9zJn2SF9wswLfipINF+E48kcMMNxFzF q4qSS/wz8gpL9dt631yseTk9m+wgmd+eNfv/jyPAJqke0+nnHbJavlK+Dqkq+5zr3Lw2 jkxf/YGWa6gjweNW4DGXn5BjStf5V4Q9H6pXaZnnq3VkYUYWaAXIH05H2Uc9MjHsoekj DBNA== 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=ZA9V5lO/+F+bF8jz1FqVjCsKgJDekjpTcf5RC67Rb+U=; b=RecSaj0soLUycuylQSxAYBDMi/m7ZW2/18ubB6Qw/CdChv2vvFtXTGM0xqOQWkucTE T1mIZIazpmWYQdharLTadQzGS5UdfPkv5Mx3HuSsNUkL4+9xS2IvPahZdYVCfy0Pcd45 RGQXFaoBrRPCsgIWnB9YKiRd1MD9cWfm9GAGthRzPWKjhwE5Pkd4p5VDOVU7tYJf1n0Y SjveYXIo6ulZKZx+Lqgb1WTWn5cDXVnL8o73d+pD3iy920NsBrn4XaKvsDyQ5fj5KWUB XD+RQ916IslmKyuQJYysZiLNGYml/ze+GETvGPlpmVEVPxAV2AHh74o2rO3LdGCA0iwC BvaQ== X-Gm-Message-State: AOAM533Aixlx7TKYoq1zJFgRrfyDNOnmYRTlcfQ3HjQ++LH2ZppCPDhf 7ssjGpiEyKSITU6CsMnjX1Mpz8Xkvk0U X-Google-Smtp-Source: ABdhPJzMkGHc7O1/Q7FmKZm+eLOtBU+xuDYiFF/nyYQhd08PMvWlme4OLTlm9m4QdO//1tq2jicPIWNqvZsR X-Received: from suichen.svl.corp.google.com ([2620:15c:2c5:13:ae7d:134a:180d:9b32]) (user=suichen job=sendgmr) by 2002:a25:6406:0:b0:64b:17e3:9dd with SMTP id y6-20020a256406000000b0064b17e309ddmr21661588ybb.186.1652781921142; Tue, 17 May 2022 03:05:21 -0700 (PDT) Date: Tue, 17 May 2022 03:05:04 -0700 Message-Id: <20220517100505.2569874-1-suichen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [RFC Patch v5 0/1] i2c: core: Adapter and client stats as sysfs attributes From: Sui Chen To: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, wsa@kernel.org, openbmc@lists.ozlabs.org, tali.perry1@gmail.com Cc: joel@jms.id.au, andrew@aj.id.au, benjaminfair@google.com, krellan@google.com, Sui Chen Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This change adds statistics to the i2c_adapter structure as Wolfram previously suggested (https://lore.kernel.org/linux-i2c/YgEYEk355t8C4J1x@shikoro/). It also adds relevant statistics to the per-address i2c_clients where applicable. The list of statistics are: - bus_errors - nacks - recovery_successes / recovery_failures (only applicable to i2c_adapter) - timeouts - messages (only applicable to i2c_client) - transfers (only applicable to i2c_adapter) The statistics are located in /sys/class/i2c-adapter/i2c-x/stats and /sys/class/i2c-adapter/i2c-x/x-xxxx/stats respectively. Since the counting is done in __i2c_transfer, where the number of messages transferred is not known upon error, the error counters are attributed to all unique addresses that appear in the message list passed into __i2c_transfer. Currently an rbtree is used to find the i2c_client located at a certain address. Would be happy to know if there is a better way of doing this. Thanks! Sui Chen (1): i2c debug counters as sysfs attributes drivers/i2c/i2c-core-base.c | 240 +++++++++++++++++++++++++++++++++++- drivers/i2c/i2c-dev.c | 94 ++++++++++++++ include/linux/i2c.h | 41 ++++++ 3 files changed, 374 insertions(+), 1 deletion(-)