Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3785188rwl; Mon, 10 Apr 2023 00:36:34 -0700 (PDT) X-Google-Smtp-Source: AKy350a7h8p9MbzWH3bmSuayp/gWi7jQnNJAozdeiRM2/qY0QMqQyT7xNG6PtigsUkd4X9JCiSuW X-Received: by 2002:a17:906:da82:b0:94a:464a:e88e with SMTP id xh2-20020a170906da8200b0094a464ae88emr7004633ejb.42.1681112194707; Mon, 10 Apr 2023 00:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681112194; cv=none; d=google.com; s=arc-20160816; b=nJ/gj7YeaqdhxFErY6Fr3iPhGlY1bF4xO3L61lnAqpZqAQJtnvibL63bGJbYn9UqFi Tn9XxB1yDqnChYjmH1N/HCACfiV/VTnyX55aEbVvoaIjzgVBF9V3coI2UFx2jIYxWkAL dqHWSH14yJ28tjcRJQB5pUJWZRDof2kj81ql5bMyFuwn5lucjIsd+NgdXcXMUpmo/s4S zO8v6Pez/E7+/Jbjg5WufJajQ2wP1pUqN6EgitVZoy6kOni4gqw8/OF8gvq+BasGFea8 g6gFkiiJhC3L/DDKiJ8Wws2z6KcoKfR7oXNCUnZv6u4hMFbcAE9R+nZKFecH1xQo3ONg VtUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=XsjqIBb7Ia4TAnyJQH7l5g8jRueBhJOfzmgtMcl/GKU=; b=yjVRXOKBEPxAcg1g+NNNy4dUCwecUVwGkz7yOFhR+pgacMY1ppR58THStd72AUgFWZ rvKcyvi8p73256xMH8te+PU6918p73lgMcAa7VwA08JaRjqpoCOvLGtGKmmGy7oHT47A O0sQzY7YyfaBEC+XdUM6A7uYdQGoiW6UqE8sCHroGctxIw5xV95R3l77aITpy9Z48owa ZYwbt+ERiwxXLu59Tq3GYjtmhRJ7IkqoMaUxCh0Bi3yRYKW2XnxuVNpfOFQ3r4FWh9yb 2h/2m974/gmWz9R+DTHRwz32NvZOKcTYaA5oBmmpzHyPYpGW4QqjZ/00LdLhEpGSkJUd t+MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=m6eMlr6I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jx7-20020a170906ca4700b0094be91a93f1si172752ejb.137.2023.04.10.00.36.10; Mon, 10 Apr 2023 00:36:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=m6eMlr6I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbjDJHcX (ORCPT + 99 others); Mon, 10 Apr 2023 03:32:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjDJHcW (ORCPT ); Mon, 10 Apr 2023 03:32:22 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E3449C2 for ; Mon, 10 Apr 2023 00:31:43 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id s93-20020a17090a2f6600b0024670ac71caso1680333pjd.4 for ; Mon, 10 Apr 2023 00:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1681111898; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=XsjqIBb7Ia4TAnyJQH7l5g8jRueBhJOfzmgtMcl/GKU=; b=m6eMlr6IRRsKYg4YgpoBxj3rZB0vKRWzHjaaj+18miNfqGNHBiDwCxMoaWbCfTF92l PZZkKOzTFNGolO0Mo08YW0qeriAIxKjlNoy8VG/ol8o53WxJtIJj9wzyDJBcx440HTvS SxkClUwOaeEz/Sbw7bcqfvLsfEIvfSiacr6NHGtHYgCSMxAmCekGenYvzUk9Y0WIIeSF iu+LGvZAsxk17Rq1Jw+dxOLV1EgAh5iuEUtky/R/+WU3S5S4bpOXuiv57vkqg70/asgF fl5shxMYIZ75Ikzf9MIZawDPCdsRAC57KUPuwcUFPbVRd+o+TFpBepaWxsaLqRUXfnJ9 2cmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681111898; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=XsjqIBb7Ia4TAnyJQH7l5g8jRueBhJOfzmgtMcl/GKU=; b=AyNvk6OX5LjO9IUfecH1aqTU8rc6gr8FHmx5Ad6STIZRr+K2lpTSLaGHiNJ2Rt4Ym5 N3jt5t1K+dsYcXvNCw69PR/7wqrRdnROoDgE0wVuCz2RgImjc9MYrL72A5dfaeBMcUQJ J7njpa7EjuLXRTiFBI1KLjWkyMQG+QVNpH0HZZefSvxRhUSLzJ6tIY0XVTTLBxMWO6+E ZeiNMz2xkQ9L7xAXR6wBXKXkZQrZmvd+TjBeYKANOz59MGavaTreqMI1IEFen6yQuQr2 eVbS5LGnmthPQXGTjO8A21FXW8bXjef74FxrX3Gtr924jK4HFfFgGDpf0+933EwJkZMM GoWA== X-Gm-Message-State: AAQBX9dQQEry9QHy0C4jl0zoBcrxT+/99l3KISVBrG8KFVNcxsLdtgk1 9qK7zPtPpV+x4jPgPovucYEXvGm9xzo= X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a17:903:13cd:b0:1a5:22f3:220e with SMTP id kd13-20020a17090313cd00b001a522f3220emr2419872plb.3.1681111898602; Mon, 10 Apr 2023 00:31:38 -0700 (PDT) Date: Mon, 10 Apr 2023 07:31:34 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230410073134.488762-1-badhri@google.com> Subject: [PATCH v1] usb: typec: tcpm: Add kernel config to wrap around tcpm logs From: Badhri Jagan Sridharan To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change adds CONFIG_TCPM_LOG_WRAPAROUND which when set allows the logs to be wrapped around. Additionally, when set, does not clear the TCPM logs when dumped. Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/Kconfig | 6 ++++++ drivers/usb/typec/tcpm/tcpm.c | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/Kconfig b/drivers/usb/typec/tcpm/Kconfig index e6b88ca4a4b9..4dd2b594dfc9 100644 --- a/drivers/usb/typec/tcpm/Kconfig +++ b/drivers/usb/typec/tcpm/Kconfig @@ -18,6 +18,12 @@ config TYPEC_TCPCI help Type-C Port Controller driver for TCPCI-compliant controller. +config TCPM_LOG_WRAPAROUND + bool "Enable TCPM log wraparound" + help + When set, wraps around TCPM logs and does not clear the logs when dumped. TCPM logs by + default gets cleared when dumped and does not wraparound when full. + if TYPEC_TCPCI config TYPEC_RT1711H diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index ab3a54662ed9..3f708749431b 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -619,7 +619,7 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args) vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args); - if (tcpm_log_full(port)) { + if (!IS_ENABLED(CONFIG_TCPM_LOG_WRAPAROUND) && tcpm_log_full(port)) { port->logbuffer_head = max(port->logbuffer_head - 1, 0); strcpy(tmpbuffer, "overflow"); } @@ -644,6 +644,10 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args) tmpbuffer); port->logbuffer_head = (port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES; + if (IS_ENABLED(CONFIG_TCPM_LOG_WRAPAROUND) && port->logbuffer_head == port->logbuffer_tail) + port->logbuffer_tail = + (port->logbuffer_tail + 1) % LOG_BUFFER_ENTRIES; + abort: mutex_unlock(&port->logbuffer_lock); } @@ -746,7 +750,8 @@ static int tcpm_debug_show(struct seq_file *s, void *v) seq_printf(s, "%s\n", port->logbuffer[tail]); tail = (tail + 1) % LOG_BUFFER_ENTRIES; } - if (!seq_has_overflowed(s)) + + if (!IS_ENABLED(CONFIG_TCPM_LOG_WRAPAROUND) && !seq_has_overflowed(s)) port->logbuffer_tail = tail; mutex_unlock(&port->logbuffer_lock); -- 2.40.0.577.gac1e443424-goog