linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] clk: add duty cycle support
@ 2018-04-20 15:34 Jerome Brunet
  2018-04-20 19:47 ` kbuild test robot
  2018-04-20 20:04 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Jerome Brunet @ 2018-04-20 15:34 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Russell King
  Cc: Jerome Brunet, Thierry Reding, Kevin Hilman, linux-clk, linux-kernel

Add the possibility to apply and query the clock signal duty cycle ratio.

This is useful when the duty cycle of the clock signal depends on some
other parameters controlled by the clock framework.

For example, the duty cycle of a divider may depends on the raw divider
setting (ratio = N / div) , which is controlled by the CCF. In such case,
going through the pwm framework to control the duty cycle ratio of this
clock would be a burden.

A clock provider is not required to implement the operation to set and get
the duty cycle. If it does not implement .get_duty_cycle(), the ratio is
assumed to be 50%.

This change also adds a new flag, CLK_DUTY_CYCLE_PARENT. This flag should
be used to indicate that a clock, such as gates and muxes, may inherit
the duty cycle ratio of its parent clock. If a clock does not provide a
get_duty_cycle() callback and has CLK_DUTY_CYCLE_PARENT, then the call
will be directly forwarded to its parent clock, if any. For
set_duty_cycle(), the clock should also have CLK_SET_RATE_PARENT for the
call to be forwarded

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---

The series has been developed to handled the sample clocks provided by
audio clock controller of amlogic's A113 SoC. To support i2s modes, this
clock need to have a 50% duty cycle ratio, while it should be just one
pulse of the parent clock in dsp modes.

Changes since v1 [0]:
 - Use a structure to hold the duty cycle ratio
 - Change the way parent traversal is done, so the core framework is
   more aware of what is going on. Pass-through ops dropped as a result
 - Only one debugfs entry for the duty cycle ratio, instead of 2
 - Minor fixes as pointed out by Stephen

[0]: https://lkml.kernel.org/r/20180416175743.20826-1-jbrunet@baylibre.com

 drivers/clk/clk.c            | 202 +++++++++++++++++++++++++++++++++++++++++--
 include/linux/clk-provider.h |  26 ++++++
 include/linux/clk.h          |  33 +++++++
 include/trace/events/clk.h   |  36 ++++++++
 4 files changed, 292 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 7af555f0e60c..a1874f2932ee 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -68,6 +68,7 @@ struct clk_core {
 	unsigned long		max_rate;
 	unsigned long		accuracy;
 	int			phase;
+	struct clk_duty		duty;
 	struct hlist_head	children;
 	struct hlist_node	child_node;
 	struct hlist_head	clks;
@@ -2401,6 +2402,172 @@ int clk_get_phase(struct clk *clk)
 }
 EXPORT_SYMBOL_GPL(clk_get_phase);
 
+static void clk_core_reset_duty_cycle_nolock(struct clk_core *core)
+{
+	/* Assume a default value of 50% */
+	core->duty.num = 1;
+	core->duty.den = 2;
+}
+
+static int clk_core_update_duty_cycle_parent_nolock(struct clk_core *core);
+
+static int clk_core_update_duty_cycle_nolock(struct clk_core *core)
+{
+	struct clk_duty *duty = &core->duty;
+	int ret = 0;
+
+	if (!core->ops->get_duty_cycle)
+		return clk_core_update_duty_cycle_parent_nolock(core);
+
+	ret = core->ops->get_duty_cycle(core->hw, duty);
+	if (ret)
+		goto reset;
+
+	/* Don't trust the clock provider too much */
+	if (duty->den == 0 || duty->num > duty->den) {
+		ret = -EINVAL;
+		goto reset;
+	}
+
+	return 0;
+
+reset:
+	clk_core_reset_duty_cycle_nolock(core);
+	return ret;
+}
+
+static int clk_core_update_duty_cycle_parent_nolock(struct clk_core *core)
+{
+	int ret = 0;
+
+	if (core->parent &&
+	    core->flags & CLK_DUTY_CYCLE_PARENT) {
+		ret = clk_core_update_duty_cycle_nolock(core->parent);
+		memcpy(&core->duty, &core->parent->duty, sizeof(core->duty));
+	} else {
+		clk_core_reset_duty_cycle_nolock(core);
+	}
+
+	return ret;
+}
+
+static int clk_core_set_duty_cycle_parent_nolock(struct clk_core *core,
+						 struct clk_duty *duty);
+
+static int clk_core_set_duty_cycle_nolock(struct clk_core *core,
+					  struct clk_duty *duty)
+{
+	int ret;
+
+	lockdep_assert_held(&prepare_lock);
+
+	if (clk_core_rate_is_protected(core))
+		return -EBUSY;
+
+	trace_clk_set_duty_cycle(core, duty);
+
+	if (!core->ops->set_duty_cycle)
+		return clk_core_set_duty_cycle_parent_nolock(core, duty);
+
+	ret = core->ops->set_duty_cycle(core->hw, duty);
+	if (!ret)
+		memcpy(&core->duty, duty, sizeof(*duty));
+
+	trace_clk_set_duty_cycle_complete(core, duty);
+
+	return ret;
+}
+
+static int clk_core_set_duty_cycle_parent_nolock(struct clk_core *core,
+						 struct clk_duty *duty)
+{
+	int ret = 0;
+
+	if (core->parent &&
+	    core->flags & (CLK_DUTY_CYCLE_PARENT | CLK_SET_RATE_PARENT)) {
+		ret = clk_core_set_duty_cycle_nolock(core->parent, duty);
+		memcpy(&core->duty, &core->parent->duty, sizeof(core->duty));
+	}
+
+	return ret;
+}
+
+/**
+ * clk_set_duty_cycle - adjust the duty cycle ratio of a clock signal
+ * @clk: clock signal source
+ * @num: numerator of the duty cycle ratio to be applied
+ * @den: denominator of the duty cycle ratio to be applied
+ *
+ * Apply the duty cycle ratio if the ratio is valid and the clock can
+ * perform this operation
+ *
+ * Returns (0) on success, a negative errno otherwise.
+ */
+int clk_set_duty_cycle(struct clk *clk, unsigned int num, unsigned int den)
+{
+	int ret;
+	struct clk_duty duty;
+
+	if (!clk)
+		return 0;
+
+	/* sanity check the ratio */
+	if (den == 0 || num > den)
+		return -EINVAL;
+
+	duty.num = num;
+	duty.den = den;
+
+	clk_prepare_lock();
+
+	if (clk->exclusive_count)
+		clk_core_rate_unprotect(clk->core);
+
+	ret = clk_core_set_duty_cycle_nolock(clk->core, &duty);
+
+	if (clk->exclusive_count)
+		clk_core_rate_protect(clk->core);
+
+	clk_prepare_unlock();
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(clk_set_duty_cycle);
+
+static int clk_core_get_scaled_duty_cycle(struct clk_core *core,
+					  unsigned int scale)
+{
+	struct clk_duty *duty = &core->duty;
+	int ret;
+
+	clk_prepare_lock();
+
+	ret = clk_core_update_duty_cycle_nolock(core);
+	if (!ret)
+		ret = mult_frac(scale, duty->num, duty->den);
+
+	clk_prepare_unlock();
+
+	return ret;
+}
+
+/**
+ * clk_get_scaled_duty_cycle - return the duty cycle ratio of a clock signal
+ * @clk: clock signal source
+ * @scale: scaling factor to be applied to represent the ratio as an integer
+ *
+ * Returns the duty cycle ratio of a clock node multiplied by the provided
+ * scaling factor, or negative errno on error.
+ */
+int clk_get_scaled_duty_cycle(struct clk *clk, unsigned int scale)
+{
+	if (!clk)
+		return 0;
+
+	return clk_core_get_scaled_duty_cycle(clk->core, scale);
+}
+EXPORT_SYMBOL_GPL(clk_get_scaled_duty_cycle);
+
 /**
  * clk_is_match - check if two clk's point to the same hardware clock
  * @p: clk compared against q
@@ -2454,12 +2621,13 @@ static void clk_summary_show_one(struct seq_file *s, struct clk_core *c,
 	if (!c)
 		return;
 
-	seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu %-3d\n",
+	seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu %5d %6d\n",
 		   level * 3 + 1, "",
 		   30 - level * 3, c->name,
 		   c->enable_count, c->prepare_count, c->protect_count,
 		   clk_core_get_rate(c), clk_core_get_accuracy(c),
-		   clk_core_get_phase(c));
+		   clk_core_get_phase(c),
+		   clk_core_get_scaled_duty_cycle(c, 100000));
 }
 
 static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c,
@@ -2481,9 +2649,9 @@ static int clk_summary_show(struct seq_file *s, void *data)
 	struct clk_core *c;
 	struct hlist_head **lists = (struct hlist_head **)s->private;
 
-	seq_puts(s, "                                 enable  prepare  protect                               \n");
-	seq_puts(s, "   clock                          count    count    count        rate   accuracy   phase\n");
-	seq_puts(s, "----------------------------------------------------------------------------------------\n");
+	seq_puts(s, "                                 enable  prepare  protect                                duty\n");
+	seq_puts(s, "   clock                          count    count    count        rate   accuracy phase  cycle\n");
+	seq_puts(s, "---------------------------------------------------------------------------------------------\n");
 
 	clk_prepare_lock();
 
@@ -2510,6 +2678,8 @@ static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
 	seq_printf(s, "\"rate\": %lu,", clk_core_get_rate(c));
 	seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy(c));
 	seq_printf(s, "\"phase\": %d", clk_core_get_phase(c));
+	seq_printf(s, "\"duty_cycle\": %u",
+		   clk_core_get_scaled_duty_cycle(c, 100000));
 }
 
 static void clk_dump_subtree(struct seq_file *s, struct clk_core *c, int level)
@@ -2571,6 +2741,7 @@ static const struct {
 	ENTRY(CLK_SET_RATE_UNGATE),
 	ENTRY(CLK_IS_CRITICAL),
 	ENTRY(CLK_OPS_PARENT_ENABLE),
+	ENTRY(CLK_DUTY_CYCLE_PARENT),
 #undef ENTRY
 };
 
@@ -2609,6 +2780,17 @@ static int possible_parents_show(struct seq_file *s, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(possible_parents);
 
+static int clk_duty_cycle_show(struct seq_file *s, void *data)
+{
+	struct clk_core *core = s->private;
+	struct clk_duty *duty = &core->duty;
+
+	seq_printf(s, "%u/%u\n", duty->num, duty->den);
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(clk_duty_cycle);
+
 static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 {
 	struct dentry *d;
@@ -2638,6 +2820,11 @@ static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 	if (!d)
 		goto err_out;
 
+	d = debugfs_create_file("clk_duty_cycle", 0444, core->dentry, core,
+				&clk_duty_cycle_fops);
+	if (!d)
+		goto err_out;
+
 	d = debugfs_create_file("clk_flags", 0444, core->dentry, core,
 				&clk_flags_fops);
 	if (!d)
@@ -2926,6 +3113,11 @@ static int __clk_core_init(struct clk_core *core)
 	else
 		core->phase = 0;
 
+	/*
+	 * Set clk's duty cycle.
+	 */
+	clk_core_update_duty_cycle_nolock(core);
+
 	/*
 	 * Set clk's rate.  The preferred method is to use .recalc_rate.  For
 	 * simple clocks and lazy developers the default fallback is to use the
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 1d25e149c1c5..48a47d17261f 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -37,6 +37,8 @@
 #define CLK_IS_CRITICAL		BIT(11) /* do not gate, ever */
 /* parents need enable during gate/ungate, set rate and re-parent */
 #define CLK_OPS_PARENT_ENABLE	BIT(12)
+/* duty cycle call may be forwarded to the parent clock */
+#define CLK_DUTY_CYCLE_PARENT	BIT(13)
 
 struct clk;
 struct clk_hw;
@@ -65,6 +67,17 @@ struct clk_rate_request {
 	struct clk_hw *best_parent_hw;
 };
 
+/**
+ * struct clk_duty - Struture encoding the duty cycle ratio of a clock
+ *
+ * @num:	Numerator of the duty cycle ratio
+ * @den:	Denominator of the duty cycle ratio
+ */
+struct clk_duty {
+	unsigned int num;
+	unsigned int den;
+};
+
 /**
  * struct clk_ops -  Callback operations for hardware clocks; these are to
  * be provided by the clock implementation, and will be called by drivers
@@ -168,6 +181,15 @@ struct clk_rate_request {
  *		by the second argument. Valid values for degrees are
  *		0-359. Return 0 on success, otherwise -EERROR.
  *
+ * @get_duty_cycle: Queries the hardware to get the current duty cycle ratio
+ *              of a clock. Returned values denominator cannot be 0 and must be
+ *              superior or equal to the numerator.
+ *
+ * @set_duty_cycle: Apply the duty cycle ratio to this clock signal specified by
+ *              the numerator (2nd argurment) and denominator (3rd  argument).
+ *              Argument must be a valid ratio (denominator > 0
+ *              and >= numerator) Return 0 on success, otherwise -EERROR.
+ *
  * @init:	Perform platform-specific initialization magic.
  *		This is not not used by any of the basic clock types.
  *		Please consider other ways of solving initialization problems
@@ -217,6 +239,10 @@ struct clk_ops {
 					   unsigned long parent_accuracy);
 	int		(*get_phase)(struct clk_hw *hw);
 	int		(*set_phase)(struct clk_hw *hw, int degrees);
+	int		(*get_duty_cycle)(struct clk_hw *hw,
+					  struct clk_duty *duty);
+	int		(*set_duty_cycle)(struct clk_hw *hw,
+					  struct clk_duty *duty);
 	void		(*init)(struct clk_hw *hw);
 	int		(*debug_init)(struct clk_hw *hw, struct dentry *dentry);
 };
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 0dbd0885b2c2..4f750c481b82 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -141,6 +141,27 @@ int clk_set_phase(struct clk *clk, int degrees);
  */
 int clk_get_phase(struct clk *clk);
 
+/**
+ * clk_set_duty_cycle - adjust the duty cycle ratio of a clock signal
+ * @clk: clock signal source
+ * @num: numerator of the duty cycle ratio to be applied
+ * @den: denominator of the duty cycle ratio to be applied
+ *
+ * Adjust the duty cycle of a clock signal by the specified ratio. Returns 0 on
+ * success, -EERROR otherwise.
+ */
+int clk_set_duty_cycle(struct clk *clk, unsigned int num, unsigned int den);
+
+/**
+ * clk_get_duty_cycle - return the duty cycle ratio of a clock signal
+ * @clk: clock signal source
+ * @scale: scaling factor to be applied to represent the ratio as an integer
+ *
+ * Returns the duty cycle ratio multiplied by the scale provided, otherwise
+ * returns -EERROR.
+ */
+int clk_get_scaled_duty_cycle(struct clk *clk, unsigned int scale);
+
 /**
  * clk_is_match - check if two clk's point to the same hardware clock
  * @p: clk compared against q
@@ -183,6 +204,18 @@ static inline long clk_get_phase(struct clk *clk)
 	return -ENOTSUPP;
 }
 
+static inline int clk_set_duty_cycle(struct clk *clk, unsigned int num,
+				     unsigned int den)
+{
+	return -ENOTSUPP;
+}
+
+static inline unsigned int clk_get_scaled_duty_cycle(struct clk *clk,
+						     unsigned int scale)
+{
+	return 0;
+}
+
 static inline bool clk_is_match(const struct clk *p, const struct clk *q)
 {
 	return p == q;
diff --git a/include/trace/events/clk.h b/include/trace/events/clk.h
index 2cd449328aee..7d6d6eae6e25 100644
--- a/include/trace/events/clk.h
+++ b/include/trace/events/clk.h
@@ -192,6 +192,42 @@ DEFINE_EVENT(clk_phase, clk_set_phase_complete,
 	TP_ARGS(core, phase)
 );
 
+DECLARE_EVENT_CLASS(clk_duty_cycle,
+
+	TP_PROTO(struct clk_core *core, struct clk_duty *duty),
+
+		    TP_ARGS(core, num, den),
+
+	TP_STRUCT__entry(
+		__string(        name,           core->name              )
+		__field( unsigned int,           duty->num               )
+		__field( unsigned int,           duty->den               )
+	),
+
+	TP_fast_assign(
+		__assign_str(name, core->name);
+		__entry->num = num;
+		__entry->den = den;
+	),
+
+	TP_printk("%s %u/%u", __get_str(name), (unsigned int)__entry->num,
+		  (unsigned int)__entry->den)
+);
+
+DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle,
+
+	TP_PROTO(struct clk_core *core, struct clk_duty *duty),
+
+	TP_ARGS(core, num, den)
+);
+
+DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle_complete,
+
+	TP_PROTO(struct clk_core *core, struct clk_duty *duty),
+
+	TP_ARGS(core, num, den)
+);
+
 #endif /* _TRACE_CLK_H */
 
 /* This part must be outside protection */
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] clk: add duty cycle support
  2018-04-20 15:34 [PATCH v2] clk: add duty cycle support Jerome Brunet
@ 2018-04-20 19:47 ` kbuild test robot
  2018-04-20 20:04 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-04-20 19:47 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: kbuild-all, Michael Turquette, Stephen Boyd, Russell King,
	Jerome Brunet, Thierry Reding, Kevin Hilman, linux-clk,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 11323 bytes --]

Hi Jerome,

I love your patch! Yet something to improve:

[auto build test ERROR on clk/clk-next]
[also build test ERROR on v4.17-rc1 next-20180420]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jerome-Brunet/clk-add-duty-cycle-support/20180421-021133
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: x86_64-randconfig-x016-201815 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from include/trace/events/clk.h:19:0,
                    from drivers//clk/clk.c:84:
   include/trace/events/clk.h: In function 'trace_clk_set_duty_cycle':
>> include/trace/events/clk.h:221:16: error: 'num' undeclared (first use in this function)
     TP_ARGS(core, num, den)
                   ^
   include/linux/tracepoint.h:148:33: note: in definition of macro '__DO_TRACE'
        ((void(*)(proto))(it_func))(args); \
                                    ^~~~
>> include/linux/tracepoint.h:189:5: note: in expansion of macro 'TP_ARGS'
        TP_ARGS(data_args),   \
        ^~~~~~~
   include/linux/tracepoint.h:349:2: note: in expansion of macro '__DECLARE_TRACE'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~
   include/linux/tracepoint.h:352:4: note: in expansion of macro 'PARAMS'
       PARAMS(__data, args))
       ^~~~~~
   include/linux/tracepoint.h:474:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:474:37: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                                        ^~~~~~
>> include/trace/events/clk.h:217:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle,
    ^~~~~~~~~~~~
>> include/trace/events/clk.h:221:2: note: in expansion of macro 'TP_ARGS'
     TP_ARGS(core, num, den)
     ^~~~~~~
   include/trace/events/clk.h:221:16: note: each undeclared identifier is reported only once for each function it appears in
     TP_ARGS(core, num, den)
                   ^
   include/linux/tracepoint.h:148:33: note: in definition of macro '__DO_TRACE'
        ((void(*)(proto))(it_func))(args); \
                                    ^~~~
>> include/linux/tracepoint.h:189:5: note: in expansion of macro 'TP_ARGS'
        TP_ARGS(data_args),   \
        ^~~~~~~
   include/linux/tracepoint.h:349:2: note: in expansion of macro '__DECLARE_TRACE'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~
   include/linux/tracepoint.h:352:4: note: in expansion of macro 'PARAMS'
       PARAMS(__data, args))
       ^~~~~~
   include/linux/tracepoint.h:474:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:474:37: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                                        ^~~~~~
>> include/trace/events/clk.h:217:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle,
    ^~~~~~~~~~~~
>> include/trace/events/clk.h:221:2: note: in expansion of macro 'TP_ARGS'
     TP_ARGS(core, num, den)
     ^~~~~~~
>> include/trace/events/clk.h:221:21: error: 'den' undeclared (first use in this function)
     TP_ARGS(core, num, den)
                        ^
   include/linux/tracepoint.h:148:33: note: in definition of macro '__DO_TRACE'
        ((void(*)(proto))(it_func))(args); \
                                    ^~~~
>> include/linux/tracepoint.h:189:5: note: in expansion of macro 'TP_ARGS'
        TP_ARGS(data_args),   \
        ^~~~~~~
   include/linux/tracepoint.h:349:2: note: in expansion of macro '__DECLARE_TRACE'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~
   include/linux/tracepoint.h:352:4: note: in expansion of macro 'PARAMS'
       PARAMS(__data, args))
       ^~~~~~
   include/linux/tracepoint.h:474:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:474:37: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                                        ^~~~~~
>> include/trace/events/clk.h:217:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle,
    ^~~~~~~~~~~~
>> include/trace/events/clk.h:221:2: note: in expansion of macro 'TP_ARGS'
     TP_ARGS(core, num, den)
     ^~~~~~~
>> include/linux/tracepoint.h:148:6: error: too many arguments to function '(void (*)(void *, struct clk_core *, struct clk_duty *))it_func'
        ((void(*)(proto))(it_func))(args); \
        ~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/tracepoint.h:187:4: note: in expansion of macro '__DO_TRACE'
       __DO_TRACE(&__tracepoint_##name,  \
       ^~~~~~~~~~
   include/linux/tracepoint.h:349:2: note: in expansion of macro '__DECLARE_TRACE'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~
   include/linux/tracepoint.h:474:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
>> include/trace/events/clk.h:217:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle,
    ^~~~~~~~~~~~
   include/trace/events/clk.h: In function 'trace_clk_set_duty_cycle_rcuidle':
>> include/trace/events/clk.h:221:16: error: 'num' undeclared (first use in this function)
     TP_ARGS(core, num, den)
                   ^
   include/linux/tracepoint.h:148:33: note: in definition of macro '__DO_TRACE'
        ((void(*)(proto))(it_func))(args); \
                                    ^~~~
   include/linux/tracepoint.h:163:5: note: in expansion of macro 'TP_ARGS'
        TP_ARGS(data_args),   \
        ^~~~~~~
   include/linux/tracepoint.h:197:2: note: in expansion of macro '__DECLARE_TRACE_RCU'
     __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~~~~~
   include/linux/tracepoint.h:198:37: note: in expansion of macro 'PARAMS'
      PARAMS(cond), PARAMS(data_proto), PARAMS(data_args)) \
                                        ^~~~~~
   include/linux/tracepoint.h:349:2: note: in expansion of macro '__DECLARE_TRACE'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~
   include/linux/tracepoint.h:352:4: note: in expansion of macro 'PARAMS'
       PARAMS(__data, args))
       ^~~~~~
   include/linux/tracepoint.h:474:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:474:37: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                                        ^~~~~~
>> include/trace/events/clk.h:217:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle,
    ^~~~~~~~~~~~
>> include/trace/events/clk.h:221:2: note: in expansion of macro 'TP_ARGS'
     TP_ARGS(core, num, den)
     ^~~~~~~
>> include/trace/events/clk.h:221:21: error: 'den' undeclared (first use in this function)
     TP_ARGS(core, num, den)
                        ^
   include/linux/tracepoint.h:148:33: note: in definition of macro '__DO_TRACE'
        ((void(*)(proto))(it_func))(args); \
                                    ^~~~
   include/linux/tracepoint.h:163:5: note: in expansion of macro 'TP_ARGS'
        TP_ARGS(data_args),   \
        ^~~~~~~
   include/linux/tracepoint.h:197:2: note: in expansion of macro '__DECLARE_TRACE_RCU'
     __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~~~~~
   include/linux/tracepoint.h:198:37: note: in expansion of macro 'PARAMS'
      PARAMS(cond), PARAMS(data_proto), PARAMS(data_args)) \
                                        ^~~~~~
   include/linux/tracepoint.h:349:2: note: in expansion of macro '__DECLARE_TRACE'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~
   include/linux/tracepoint.h:352:4: note: in expansion of macro 'PARAMS'
       PARAMS(__data, args))
       ^~~~~~
   include/linux/tracepoint.h:474:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~
   include/linux/tracepoint.h:474:37: note: in expansion of macro 'PARAMS'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
                                        ^~~~~~
>> include/trace/events/clk.h:217:1: note: in expansion of macro 'DEFINE_EVENT'
    DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle,
    ^~~~~~~~~~~~
>> include/trace/events/clk.h:221:2: note: in expansion of macro 'TP_ARGS'
     TP_ARGS(core, num, den)
     ^~~~~~~
>> include/linux/tracepoint.h:148:6: error: too many arguments to function '(void (*)(void *, struct clk_core *, struct clk_duty *))it_func'
        ((void(*)(proto))(it_func))(args); \
        ~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/tracepoint.h:161:4: note: in expansion of macro '__DO_TRACE'
       __DO_TRACE(&__tracepoint_##name,  \
       ^~~~~~~~~~
   include/linux/tracepoint.h:197:2: note: in expansion of macro '__DECLARE_TRACE_RCU'
     __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~~~~~
   include/linux/tracepoint.h:349:2: note: in expansion of macro '__DECLARE_TRACE'
     __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
     ^~~~~~~~~~~~~~~
   include/linux/tracepoint.h:474:2: note: in expansion of macro 'DECLARE_TRACE'
     DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     ^~~~~~~~~~~~~

vim +/num +221 include/trace/events/clk.h

   194	
 > 195	DECLARE_EVENT_CLASS(clk_duty_cycle,
   196	
   197		TP_PROTO(struct clk_core *core, struct clk_duty *duty),
   198	
 > 199			    TP_ARGS(core, num, den),
   200	
 > 201		TP_STRUCT__entry(
 > 202			__string(        name,           core->name              )
 > 203			__field( unsigned int,           duty->num               )
   204			__field( unsigned int,           duty->den               )
   205		),
   206	
 > 207		TP_fast_assign(
   208			__assign_str(name, core->name);
   209			__entry->num = num;
   210			__entry->den = den;
   211		),
   212	
 > 213		TP_printk("%s %u/%u", __get_str(name), (unsigned int)__entry->num,
 > 214			  (unsigned int)__entry->den)
   215	);
   216	
 > 217	DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle,
   218	
   219		TP_PROTO(struct clk_core *core, struct clk_duty *duty),
   220	
 > 221		TP_ARGS(core, num, den)
   222	);
   223	
 > 224	DEFINE_EVENT(clk_duty_cycle, clk_set_duty_cycle_complete,
   225	
   226		TP_PROTO(struct clk_core *core, struct clk_duty *duty),
   227	
   228		TP_ARGS(core, num, den)
   229	);
   230	
   231	#endif /* _TRACE_CLK_H */
   232	
   233	/* This part must be outside protection */
 > 234	#include <trace/define_trace.h>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26958 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] clk: add duty cycle support
  2018-04-20 15:34 [PATCH v2] clk: add duty cycle support Jerome Brunet
  2018-04-20 19:47 ` kbuild test robot
@ 2018-04-20 20:04 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-04-20 20:04 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: kbuild-all, Michael Turquette, Stephen Boyd, Russell King,
	Jerome Brunet, Thierry Reding, Kevin Hilman, linux-clk,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 12499 bytes --]

Hi Jerome,

I love your patch! Yet something to improve:

[auto build test ERROR on clk/clk-next]
[also build test ERROR on v4.17-rc1 next-20180420]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jerome-Brunet/clk-add-duty-cycle-support/20180421-021133
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: powerpc-ppc6xx_defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^~~~~~~~~~~~~~~~~~~
   include/trace/trace_events.h:399:6: note: in expansion of macro 'offsetof'
         offsetof(typeof(field), item),  \
         ^~~~~~~~
   include/trace/trace_events.h:415:29: note: in expansion of macro '__field_ext'
    #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
                                ^~~~~~~~~~~
   include/trace/events/clk.h:203:3: note: in expansion of macro '__field'
      __field( unsigned int,           duty->num               )
      ^~~~~~~
   include/trace/trace_events.h:400:18: error: 'struct trace_event_raw_clk_duty_cycle' has no member named 'duty'
         sizeof(field.item),   \
                     ^
   include/trace/trace_events.h:454:2: note: in definition of macro 'DECLARE_EVENT_CLASS'
     tstruct;       \
     ^~~~~~~
   include/trace/events/clk.h:201:2: note: in expansion of macro 'TP_STRUCT__entry'
     TP_STRUCT__entry(
     ^~~~~~~~~~~~~~~~
   include/trace/trace_events.h:415:29: note: in expansion of macro '__field_ext'
    #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
                                ^~~~~~~~~~~
   include/trace/events/clk.h:203:3: note: in expansion of macro '__field'
      __field( unsigned int,           duty->num               )
      ^~~~~~~
   include/linux/compiler-gcc.h:166:2: error: 'struct trace_event_raw_clk_duty_cycle' has no member named 'duty'
     __builtin_offsetof(a, b)
     ^
   include/trace/trace_events.h:454:2: note: in definition of macro 'DECLARE_EVENT_CLASS'
     tstruct;       \
     ^~~~~~~
   include/trace/events/clk.h:201:2: note: in expansion of macro 'TP_STRUCT__entry'
     TP_STRUCT__entry(
     ^~~~~~~~~~~~~~~~
   include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^~~~~~~~~~~~~~~~~~~
   include/trace/trace_events.h:399:6: note: in expansion of macro 'offsetof'
         offsetof(typeof(field), item),  \
         ^~~~~~~~
   include/trace/trace_events.h:415:29: note: in expansion of macro '__field_ext'
    #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
                                ^~~~~~~~~~~
   include/trace/events/clk.h:204:3: note: in expansion of macro '__field'
      __field( unsigned int,           duty->den               )
      ^~~~~~~
   include/trace/trace_events.h:400:18: error: 'struct trace_event_raw_clk_duty_cycle' has no member named 'duty'
         sizeof(field.item),   \
                     ^
   include/trace/trace_events.h:454:2: note: in definition of macro 'DECLARE_EVENT_CLASS'
     tstruct;       \
     ^~~~~~~
   include/trace/events/clk.h:201:2: note: in expansion of macro 'TP_STRUCT__entry'
     TP_STRUCT__entry(
     ^~~~~~~~~~~~~~~~
   include/trace/trace_events.h:415:29: note: in expansion of macro '__field_ext'
    #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
                                ^~~~~~~~~~~
   include/trace/events/clk.h:204:3: note: in expansion of macro '__field'
      __field( unsigned int,           duty->den               )
      ^~~~~~~
   In file included from include/trace/define_trace.h:96:0,
                    from include/trace/events/clk.h:234,
                    from drivers//clk/clk.c:84:
   include/trace/events/clk.h: In function 'trace_event_get_offsets_clk_duty_cycle':
   include/linux/compiler-gcc.h:166:2: error: 'struct trace_event_raw_clk_duty_cycle' has no member named '__data'
     __builtin_offsetof(a, b)
     ^
   include/trace/trace_events.h:534:2: note: in definition of macro 'DECLARE_EVENT_CLASS'
     tstruct;       \
     ^~~~~~~
   include/trace/events/clk.h:201:2: note: in expansion of macro 'TP_STRUCT__entry'
     TP_STRUCT__entry(
     ^~~~~~~~~~~~~~~~
   include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^~~~~~~~~~~~~~~~~~~
   include/trace/trace_events.h:494:11: note: in expansion of macro 'offsetof'
              offsetof(typeof(*entry), __data); \
              ^~~~~~~~
   include/trace/trace_events.h:499:29: note: in expansion of macro '__dynamic_array'
    #define __string(item, src) __dynamic_array(char, item,   \
                                ^~~~~~~~~~~~~~~
   include/trace/events/clk.h:202:3: note: in expansion of macro '__string'
      __string(        name,           core->name              )
      ^~~~~~~~
   In file included from include/trace/define_trace.h:96:0,
                    from include/trace/events/clk.h:234,
                    from drivers//clk/clk.c:84:
   include/trace/events/clk.h: In function 'trace_event_raw_event_clk_duty_cycle':
   include/trace/events/clk.h:199:21: error: 'num' undeclared (first use in this function)
          TP_ARGS(core, num, den),
                        ^
   include/trace/trace_events.h:709:64: note: in definition of macro 'DECLARE_EVENT_CLASS'
     __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
                                                                   ^~~~
   include/trace/events/clk.h:199:7: note: in expansion of macro 'TP_ARGS'
          TP_ARGS(core, num, den),
          ^~~~~~~
>> include/trace/events/clk.h:199:26: error: 'den' undeclared (first use in this function); did you mean '_end'?
          TP_ARGS(core, num, den),
                             ^
   include/trace/trace_events.h:709:64: note: in definition of macro 'DECLARE_EVENT_CLASS'
     __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
                                                                   ^~~~
   include/trace/events/clk.h:199:7: note: in expansion of macro 'TP_ARGS'
          TP_ARGS(core, num, den),
          ^~~~~~~
   include/trace/trace_events.h:709:16: error: too many arguments to function 'trace_event_get_offsets_clk_duty_cycle'
     __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
                   ^
   include/trace/events/clk.h:195:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
    DECLARE_EVENT_CLASS(clk_duty_cycle,
    ^~~~~~~~~~~~~~~~~~~
   In file included from include/trace/define_trace.h:96:0,
                    from include/trace/events/clk.h:234,
                    from drivers//clk/clk.c:84:
   include/trace/trace_events.h:527:27: note: declared here
    static inline notrace int trace_event_get_offsets_##call(  \
                              ^
   include/trace/events/clk.h:195:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
    DECLARE_EVENT_CLASS(clk_duty_cycle,
    ^~~~~~~~~~~~~~~~~~~
   In file included from include/trace/define_trace.h:96:0,
                    from include/trace/events/clk.h:234,
                    from drivers//clk/clk.c:84:
   include/trace/events/clk.h:209:10: error: 'struct trace_event_raw_clk_duty_cycle' has no member named 'num'
      __entry->num = num;
             ^
   include/trace/trace_events.h:719:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/events/clk.h:207:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~
   include/trace/events/clk.h:210:10: error: 'struct trace_event_raw_clk_duty_cycle' has no member named 'den'
      __entry->den = den;
             ^
   include/trace/trace_events.h:719:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/events/clk.h:207:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~
   In file included from include/trace/define_trace.h:97:0,
                    from include/trace/events/clk.h:234,
                    from drivers//clk/clk.c:84:
   include/trace/events/clk.h: In function 'perf_trace_clk_duty_cycle':
   include/trace/events/clk.h:199:21: error: 'num' undeclared (first use in this function)
          TP_ARGS(core, num, den),
                        ^
   include/trace/perf.h:46:64: note: in definition of macro 'DECLARE_EVENT_CLASS'
     __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
                                                                   ^~~~
   include/trace/events/clk.h:199:7: note: in expansion of macro 'TP_ARGS'
          TP_ARGS(core, num, den),
          ^~~~~~~
>> include/trace/events/clk.h:199:26: error: 'den' undeclared (first use in this function); did you mean '_end'?
          TP_ARGS(core, num, den),
                             ^
   include/trace/perf.h:46:64: note: in definition of macro 'DECLARE_EVENT_CLASS'
     __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
                                                                   ^~~~
   include/trace/events/clk.h:199:7: note: in expansion of macro 'TP_ARGS'
          TP_ARGS(core, num, den),
          ^~~~~~~
   include/trace/perf.h:46:16: error: too many arguments to function 'trace_event_get_offsets_clk_duty_cycle'
     __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
                   ^
   include/trace/events/clk.h:195:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
    DECLARE_EVENT_CLASS(clk_duty_cycle,
    ^~~~~~~~~~~~~~~~~~~
   In file included from include/trace/define_trace.h:96:0,
                    from include/trace/events/clk.h:234,
                    from drivers//clk/clk.c:84:
   include/trace/trace_events.h:527:27: note: declared here
    static inline notrace int trace_event_get_offsets_##call(  \
                              ^
   include/trace/events/clk.h:195:1: note: in expansion of macro 'DECLARE_EVENT_CLASS'
    DECLARE_EVENT_CLASS(clk_duty_cycle,
    ^~~~~~~~~~~~~~~~~~~
   In file included from include/trace/define_trace.h:97:0,
                    from include/trace/events/clk.h:234,
                    from drivers//clk/clk.c:84:
   include/trace/events/clk.h:209:10: error: 'struct trace_event_raw_clk_duty_cycle' has no member named 'num'
      __entry->num = num;
             ^
   include/trace/perf.h:66:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/events/clk.h:207:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~
   include/trace/events/clk.h:210:10: error: 'struct trace_event_raw_clk_duty_cycle' has no member named 'den'
      __entry->den = den;
             ^
   include/trace/perf.h:66:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/events/clk.h:207:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~

vim +199 include/trace/events/clk.h

   196	
   197		TP_PROTO(struct clk_core *core, struct clk_duty *duty),
   198	
 > 199			    TP_ARGS(core, num, den),
   200	
   201		TP_STRUCT__entry(
   202			__string(        name,           core->name              )
   203			__field( unsigned int,           duty->num               )
   204			__field( unsigned int,           duty->den               )
   205		),
   206	
   207		TP_fast_assign(
   208			__assign_str(name, core->name);
   209			__entry->num = num;
   210			__entry->den = den;
   211		),
   212	
   213		TP_printk("%s %u/%u", __get_str(name), (unsigned int)__entry->num,
   214			  (unsigned int)__entry->den)
   215	);
   216	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29455 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-20 20:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 15:34 [PATCH v2] clk: add duty cycle support Jerome Brunet
2018-04-20 19:47 ` kbuild test robot
2018-04-20 20:04 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).