From patchwork Fri Sep 20 08:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13808352 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 2FE8713FD72 for ; Fri, 20 Sep 2024 08:58:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726822726; cv=none; b=HNY+Xs1C6eh/XgPv7hZn5nkpML4yBtEOnX3n58S6WVoQ5bjpnm/w4uxoWfG+nHA317aFjLo3Iv14tM8Q7tZc4Nm2wo/rLAtjv/ejE6PqdEEWYkNe8KZU/hinniJ7M81xWwWD9TG4UDLB1JsT1CMb1ykrAgeyqNBgtkT5wSyglXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726822726; c=relaxed/simple; bh=gZdqMH8oXfOl6cq31nv02mYK0c+V0C81z1p0WR1vLy8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lmt2faJoo0cnVjJPuwCiDFQ7LZ+qRygBs6Lzcmcgs6Mt68HSPdhpyp/nn+PfGl3fWnAXTv+ILYtjSDZMvIlcs4BY3Gw8hnYbwbETSLqjsueWcmqW6nicdFTQmiEef3lKSBqSviIjrl5pIZDi6WErGuMk8qtXof4/dVhWPkGPlKY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=v2A6KZq6; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="v2A6KZq6" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42ca4e0299eso14319885e9.2 for ; Fri, 20 Sep 2024 01:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726822722; x=1727427522; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nyvnzhANddz0dxiv8L9gwaZD7AX+gYVBoZw7Mny87K4=; b=v2A6KZq614YNDf7J+KigF1e/s0+56Ylci1XuMp3WAfLgRZ3BFN1zWmSL1YIjSMHBEz X3tWIvfDkOkK397yfIPL/KjDlp8yR3UFJYF8j6zb7jFRwvBljNYsV6Eifbz/gTOeHs+r wfC/JkncElVOt2OTQBtpvx9aCOcuG7uL+1KhIlBIzvC7xEQvBzGXfR3idoVspeo7kP/V jWnorDo9JV44s+fMT2xDdfZ2zrLBdJNGEHzP2zRFBJMn6u3ZSXCC1L4C56VfRHYIqB7U o9L7Bq0/mWg9fWqvovhs2Gc01uJn+NJ9NPEf6OyDeZLFmsUXrp+x4HxXbLpvOkJx3cP+ ZXfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726822722; x=1727427522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nyvnzhANddz0dxiv8L9gwaZD7AX+gYVBoZw7Mny87K4=; b=aUOtyCtZxEI6k8aN0mogXCzdhjrybB9/ZglV1dfPd4b9uiTHqzN6ZhCNstnLr0ag5v 2hDZjFoeK3Kiz+MNy5mZ9WBBcHZpV6vBxDWEtaYHunjAPi2kNNW7bVmh1YMlgBo6X+6H 9cL+vSGcceKWv/UMwfXCZLr4AfhmT5RInKg8jfkYW7jeKrC3mOQHSKFdQQtD3J/ktBvR TlEP2Yv6z4vOGE2lE1L+n5SF7AKDGZB/bhZa1koGifpZpKXLsTF9bpOoOjMLDUCDel7n EPyehm2TLeOxLtGYhTxUF83WfKFSRCNcLUuf1u1CDQsfJHxptTGgjG+X+gcHWQsGpebL 3TyQ== X-Forwarded-Encrypted: i=1; AJvYcCUgM64I1ax89j5ZlNwsYhqzZG0pfABzBl4Q2mZUdcHYwgEHLzqKHQJ/hfoaCtmJkc1dR5Td+Kb/HPMz15xJzhxnomU=@vger.kernel.org X-Gm-Message-State: AOJu0YzAoavjywJMteu0DpmCeY05KKpCusqOnJ+FXWqtfsAE5KNybHxn Ye8xWPeU1duvQmswsRsKl1FJhWYJaDTCytWezLDLERIO9vzO/vw00BcFaK5TpKg= X-Google-Smtp-Source: AGHT+IF74IaF3BZY0zxyWctKvGK2dCFXneFIST5v5/s1RO0JPggvKTtUF0K/LiBdLiNvpPRJ5HIH7Q== X-Received: by 2002:a5d:4e09:0:b0:376:efb7:d19a with SMTP id ffacd0b85a97d-37a4319e028mr1024284f8f.44.1726822722523; Fri, 20 Sep 2024 01:58:42 -0700 (PDT) Received: from localhost (p200300f65f01db004d6a46a6454a1385.dip0.t-ipconnect.de. [2003:f6:5f01:db00:4d6a:46a6:454a:1385]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e75b7ac86sm42343645e9.15.2024.09.20.01.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 01:58:41 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: linux-pwm@vger.kernel.org Cc: Trevor Gamblin , David Lechner , Kent Gibson , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , linux-trace-kernel@vger.kernel.org Subject: [PATCH v5 4/8] pwm: Add tracing for waveform callbacks Date: Fri, 20 Sep 2024 10:58:00 +0200 Message-ID: <1d71879b0de3bf01459c7a9d0f040d43eb5ace56.1726819463.git.u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6305; i=u.kleine-koenig@baylibre.com; h=from:subject:message-id; bh=gZdqMH8oXfOl6cq31nv02mYK0c+V0C81z1p0WR1vLy8=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBm7TkgLyLkRYAJsgOfG4kjb6c/Q1+kyC0n6vV2F 5uAphHqvi2JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZu05IAAKCRCPgPtYfRL+ TqlRB/44H8ZbeoTFk9KmhnAh1OhgUYlm7OkMOR7aj//nj67NTrtlJ5AYirp4wN+uzAf0fFyNzRh Db+bLmKMMKpQzbPYDmpeHfWTlSOBbzQQYhOCERh47BG/6NoAGlOSM1fQjP1YxozalocMmcVDA/F JeiZkJKhLraz7E1cA750gXGGVIWr6l+k8sAa3+ps4GXsvDfeWEMfle5cje+ktY98sJn5mDpBECy QpEDjBSibhOrWim5Ll5yhhHS5S5ynjcLnE7NOa1yoI/K8+8Yusuqi+6COnGJADvjK+7KoGbUu0I zwhXkbOq9g7NZ34bml3JwqiyyXGXvQEKQUQZ/b8NK8r27uUI X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 This adds trace events for the recently introduced waveform callbacks. With the introduction of some helper macros consistency among the different events is ensured. Signed-off-by: Uwe Kleine-König --- drivers/pwm/core.c | 24 +++++-- include/trace/events/pwm.h | 134 ++++++++++++++++++++++++++++++++++--- 2 files changed, 146 insertions(+), 12 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 1cefc6e9c10d..b688c72aba1f 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -164,30 +164,46 @@ static int __pwm_round_waveform_tohw(struct pwm_chip *chip, struct pwm_device *p const struct pwm_waveform *wf, void *wfhw) { const struct pwm_ops *ops = chip->ops; + int ret; - return ops->round_waveform_tohw(chip, pwm, wf, wfhw); + ret = ops->round_waveform_tohw(chip, pwm, wf, wfhw); + trace_pwm_round_waveform_tohw(pwm, wf, wfhw, ret); + + return ret; } static int __pwm_round_waveform_fromhw(struct pwm_chip *chip, struct pwm_device *pwm, const void *wfhw, struct pwm_waveform *wf) { const struct pwm_ops *ops = chip->ops; + int ret; - return ops->round_waveform_fromhw(chip, pwm, wfhw, wf); + ret = ops->round_waveform_fromhw(chip, pwm, wfhw, wf); + trace_pwm_round_waveform_fromhw(pwm, wfhw, wf, ret); + + return ret; } static int __pwm_read_waveform(struct pwm_chip *chip, struct pwm_device *pwm, void *wfhw) { const struct pwm_ops *ops = chip->ops; + int ret; - return ops->read_waveform(chip, pwm, wfhw); + ret = ops->read_waveform(chip, pwm, wfhw); + trace_pwm_read_waveform(pwm, wfhw, ret); + + return ret; } static int __pwm_write_waveform(struct pwm_chip *chip, struct pwm_device *pwm, const void *wfhw) { const struct pwm_ops *ops = chip->ops; + int ret; - return ops->write_waveform(chip, pwm, wfhw); + ret = ops->write_waveform(chip, pwm, wfhw); + trace_pwm_write_waveform(pwm, wfhw, ret); + + return ret; } #define WFHWSIZE 20 diff --git a/include/trace/events/pwm.h b/include/trace/events/pwm.h index 8022701c446d..8ba898fd335c 100644 --- a/include/trace/events/pwm.h +++ b/include/trace/events/pwm.h @@ -8,15 +8,135 @@ #include #include +#define TP_PROTO_pwm(args...) \ + TP_PROTO(struct pwm_device *pwm, args) + +#define TP_ARGS_pwm(args...) \ + TP_ARGS(pwm, args) + +#define TP_STRUCT__entry_pwm(args...) \ + TP_STRUCT__entry( \ + __field(unsigned int, chipid) \ + __field(unsigned int, hwpwm) \ + args) + +#define TP_fast_assign_pwm(args...) \ + TP_fast_assign( \ + __entry->chipid = pwm->chip->id; \ + __entry->hwpwm = pwm->hwpwm; \ + args) + +#define TP_printk_pwm(fmt, args...) \ + TP_printk("pwmchip%u.%u: " fmt, __entry->chipid, __entry->hwpwm, args) + +#define __field_pwmwf(wf) \ + __field(u64, wf ## _period_length_ns) \ + __field(u64, wf ## _duty_length_ns) \ + __field(u64, wf ## _duty_offset_ns) \ + +#define fast_assign_pwmwf(wf) \ + __entry->wf ## _period_length_ns = wf->period_length_ns; \ + __entry->wf ## _duty_length_ns = wf->duty_length_ns; \ + __entry->wf ## _duty_offset_ns = wf->duty_offset_ns + +#define printk_pwmwf_format(wf) \ + "%lld/%lld [+%lld]" + +#define printk_pwmwf_formatargs(wf) \ + __entry->wf ## _duty_length_ns, __entry->wf ## _period_length_ns, __entry->wf ## _duty_offset_ns + +TRACE_EVENT(pwm_round_waveform_tohw, + + TP_PROTO_pwm(const struct pwm_waveform *wf, void *wfhw, int err), + + TP_ARGS_pwm(wf, wfhw, err), + + TP_STRUCT__entry_pwm( + __field_pwmwf(wf) + __field(void *, wfhw) + __field(int, err) + ), + + TP_fast_assign_pwm( + fast_assign_pwmwf(wf); + __entry->wfhw = wfhw; + __entry->err = err; + ), + + TP_printk_pwm(printk_pwmwf_format(wf) " > %p err=%d", + printk_pwmwf_formatargs(wf), __entry->wfhw, __entry->err) +); + +TRACE_EVENT(pwm_round_waveform_fromhw, + + TP_PROTO_pwm(const void *wfhw, struct pwm_waveform *wf, int err), + + TP_ARGS_pwm(wfhw, wf, err), + + TP_STRUCT__entry_pwm( + __field(const void *, wfhw) + __field_pwmwf(wf) + __field(int, err) + ), + + TP_fast_assign_pwm( + __entry->wfhw = wfhw; + fast_assign_pwmwf(wf); + __entry->err = err; + ), + + TP_printk_pwm("%p > " printk_pwmwf_format(wf) " err=%d", + __entry->wfhw, printk_pwmwf_formatargs(wf), __entry->err) +); + +TRACE_EVENT(pwm_read_waveform, + + TP_PROTO_pwm(void *wfhw, int err), + + TP_ARGS_pwm(wfhw, err), + + TP_STRUCT__entry_pwm( + __field(void *, wfhw) + __field(int, err) + ), + + TP_fast_assign_pwm( + __entry->wfhw = wfhw; + __entry->err = err; + ), + + TP_printk_pwm("%p err=%d", + __entry->wfhw, __entry->err) +); + +TRACE_EVENT(pwm_write_waveform, + + TP_PROTO_pwm(const void *wfhw, int err), + + TP_ARGS_pwm(wfhw, err), + + TP_STRUCT__entry_pwm( + __field(const void *, wfhw) + __field(int, err) + ), + + TP_fast_assign_pwm( + __entry->wfhw = wfhw; + __entry->err = err; + ), + + TP_printk_pwm("%p err=%d", + __entry->wfhw, __entry->err) +); + + DECLARE_EVENT_CLASS(pwm, TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err), TP_ARGS(pwm, state, err), - TP_STRUCT__entry( - __field(unsigned int, chipid) - __field(unsigned int, hwpwm) + TP_STRUCT__entry_pwm( __field(u64, period) __field(u64, duty_cycle) __field(enum pwm_polarity, polarity) @@ -24,9 +144,7 @@ DECLARE_EVENT_CLASS(pwm, __field(int, err) ), - TP_fast_assign( - __entry->chipid = pwm->chip->id; - __entry->hwpwm = pwm->hwpwm; + TP_fast_assign_pwm( __entry->period = state->period; __entry->duty_cycle = state->duty_cycle; __entry->polarity = state->polarity; @@ -34,8 +152,8 @@ DECLARE_EVENT_CLASS(pwm, __entry->err = err; ), - TP_printk("pwmchip%u.%u: period=%llu duty_cycle=%llu polarity=%d enabled=%d err=%d", - __entry->chipid, __entry->hwpwm, __entry->period, __entry->duty_cycle, + TP_printk_pwm("period=%llu duty_cycle=%llu polarity=%d enabled=%d err=%d", + __entry->period, __entry->duty_cycle, __entry->polarity, __entry->enabled, __entry->err) );