All of lore.kernel.org
 help / color / mirror / Atom feed
From: preeti@linux.vnet.ibm.com (Preeti U Murthy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] clockevents: introduce ->set_dev_mode() which can return error
Date: Wed, 10 Dec 2014 08:57:07 +0530	[thread overview]
Message-ID: <5487BD8B.5060903@linux.vnet.ibm.com> (raw)
In-Reply-To: <1418162614-19182-2-git-send-email-khilman@kernel.org>

On 12/10/2014 03:33 AM, Kevin Hilman wrote:
> From: Viresh Kumar <viresh.kumar@linaro.org>
> 
> Currently, the ->set_mode() method of a clockevent device is not
> allowed to fail, so it has no return value.  In order to add new
> clockevent modes, and allow the setting of those modes to fail, we
> need the clockevent core to be able to detect when setting a mode
> fails.
> 
> To allow detection of mode setting failures, introduce a new method
> ->set_dev_mode() which can return an error if the given mode is not
> supported or fails.
> 
> Since all current modes are still not allowed to fail, the core code
> simply WARNs if any modes fail.  Future patches that add new mode
> support will add proper error recovery based on failure conditions.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> Reviewed-by: Kevin Hilman <khilman@linaro.org>
> [khilman: rework changelogs, minor formatting/checkpatch cleanups]
> Signed-off-by: Kevin Hilman <khilman@linaro.org>
> ---
>  include/linux/clockchips.h |  5 ++++-
>  kernel/time/clockevents.c  | 21 ++++++++++++++++++---
>  kernel/time/timer_list.c   |  5 ++++-
>  3 files changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
> index 2e4cb67f6e56..d969659cf688 100644
> --- a/include/linux/clockchips.h
> +++ b/include/linux/clockchips.h
> @@ -81,7 +81,8 @@ enum clock_event_mode {
>   * @mode:		operating mode assigned by the management code
>   * @features:		features
>   * @retries:		number of forced programming retries
> - * @set_mode:		set mode function
> + * @set_dev_mode:	set dev mode function
> + * @set_mode:		set mode function (deprecated, use set_dev_mode instead)
>   * @broadcast:		function to broadcast events
>   * @min_delta_ticks:	minimum delta value in ticks stored for reconfiguration
>   * @max_delta_ticks:	maximum delta value in ticks stored for reconfiguration
> @@ -109,6 +110,8 @@ struct clock_event_device {
>  	unsigned long		retries;
> 
>  	void			(*broadcast)(const struct cpumask *mask);
> +	int			(*set_dev_mode)(enum clock_event_mode mode,
> +						struct clock_event_device *);
>  	void			(*set_mode)(enum clock_event_mode mode,
>  					    struct clock_event_device *);
>  	void			(*suspend)(struct clock_event_device *);
> diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
> index 55449909f114..f7614041240e 100644
> --- a/kernel/time/clockevents.c
> +++ b/kernel/time/clockevents.c
> @@ -105,7 +105,16 @@ void clockevents_set_mode(struct clock_event_device *dev,
>  				 enum clock_event_mode mode)
>  {
>  	if (dev->mode != mode) {
> -		dev->set_mode(mode, dev);
> +		if (dev->set_dev_mode) {
> +			int ret = dev->set_dev_mode(mode, dev);
> +
> +			/* Currently available modes shouldn't fail */
> +			WARN_ONCE(ret, "Requested mode: %d, error: %d\n",
> +				  mode, ret);
> +		} else {
> +			dev->set_mode(mode, dev);
> +		}
> +
>  		dev->mode = mode;
> 
>  		/*
> @@ -448,8 +457,14 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq)
>  	if (dev->mode == CLOCK_EVT_MODE_ONESHOT)
>  		return clockevents_program_event(dev, dev->next_event, false);
> 
> -	if (dev->mode == CLOCK_EVT_MODE_PERIODIC)
> -		dev->set_mode(CLOCK_EVT_MODE_PERIODIC, dev);
> +	if (dev->mode == CLOCK_EVT_MODE_PERIODIC) {
> +		/* Shouldn't fail while switching to PERIODIC MODE */
> +		if (dev->set_dev_mode)
> +			WARN_ON_ONCE(dev->set_dev_mode(CLOCK_EVT_MODE_PERIODIC,
> +						       dev));
> +		else
> +			dev->set_mode(CLOCK_EVT_MODE_PERIODIC, dev);
> +	}
> 
>  	return 0;
>  }
> diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
> index 61ed862cdd37..957a04951ef0 100644
> --- a/kernel/time/timer_list.c
> +++ b/kernel/time/timer_list.c
> @@ -229,7 +229,10 @@ print_tickdevice(struct seq_file *m, struct tick_device *td, int cpu)
>  	SEQ_printf(m, "\n");
> 
>  	SEQ_printf(m, " set_mode:       ");
> -	print_name_offset(m, dev->set_mode);
> +	if (dev->set_dev_mode)
> +		print_name_offset(m, dev->set_dev_mode);
> +	else
> +		print_name_offset(m, dev->set_mode);
>  	SEQ_printf(m, "\n");
> 
>  	SEQ_printf(m, " event_handler:  ");
> 
Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>

WARNING: multiple messages have this Message-ID (diff)
From: Preeti U Murthy <preeti@linux.vnet.ibm.com>
To: Kevin Hilman <khilman@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH 1/2] clockevents: introduce ->set_dev_mode() which can return error
Date: Wed, 10 Dec 2014 08:57:07 +0530	[thread overview]
Message-ID: <5487BD8B.5060903@linux.vnet.ibm.com> (raw)
In-Reply-To: <1418162614-19182-2-git-send-email-khilman@kernel.org>

On 12/10/2014 03:33 AM, Kevin Hilman wrote:
> From: Viresh Kumar <viresh.kumar@linaro.org>
> 
> Currently, the ->set_mode() method of a clockevent device is not
> allowed to fail, so it has no return value.  In order to add new
> clockevent modes, and allow the setting of those modes to fail, we
> need the clockevent core to be able to detect when setting a mode
> fails.
> 
> To allow detection of mode setting failures, introduce a new method
> ->set_dev_mode() which can return an error if the given mode is not
> supported or fails.
> 
> Since all current modes are still not allowed to fail, the core code
> simply WARNs if any modes fail.  Future patches that add new mode
> support will add proper error recovery based on failure conditions.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> Reviewed-by: Kevin Hilman <khilman@linaro.org>
> [khilman: rework changelogs, minor formatting/checkpatch cleanups]
> Signed-off-by: Kevin Hilman <khilman@linaro.org>
> ---
>  include/linux/clockchips.h |  5 ++++-
>  kernel/time/clockevents.c  | 21 ++++++++++++++++++---
>  kernel/time/timer_list.c   |  5 ++++-
>  3 files changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
> index 2e4cb67f6e56..d969659cf688 100644
> --- a/include/linux/clockchips.h
> +++ b/include/linux/clockchips.h
> @@ -81,7 +81,8 @@ enum clock_event_mode {
>   * @mode:		operating mode assigned by the management code
>   * @features:		features
>   * @retries:		number of forced programming retries
> - * @set_mode:		set mode function
> + * @set_dev_mode:	set dev mode function
> + * @set_mode:		set mode function (deprecated, use set_dev_mode instead)
>   * @broadcast:		function to broadcast events
>   * @min_delta_ticks:	minimum delta value in ticks stored for reconfiguration
>   * @max_delta_ticks:	maximum delta value in ticks stored for reconfiguration
> @@ -109,6 +110,8 @@ struct clock_event_device {
>  	unsigned long		retries;
> 
>  	void			(*broadcast)(const struct cpumask *mask);
> +	int			(*set_dev_mode)(enum clock_event_mode mode,
> +						struct clock_event_device *);
>  	void			(*set_mode)(enum clock_event_mode mode,
>  					    struct clock_event_device *);
>  	void			(*suspend)(struct clock_event_device *);
> diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
> index 55449909f114..f7614041240e 100644
> --- a/kernel/time/clockevents.c
> +++ b/kernel/time/clockevents.c
> @@ -105,7 +105,16 @@ void clockevents_set_mode(struct clock_event_device *dev,
>  				 enum clock_event_mode mode)
>  {
>  	if (dev->mode != mode) {
> -		dev->set_mode(mode, dev);
> +		if (dev->set_dev_mode) {
> +			int ret = dev->set_dev_mode(mode, dev);
> +
> +			/* Currently available modes shouldn't fail */
> +			WARN_ONCE(ret, "Requested mode: %d, error: %d\n",
> +				  mode, ret);
> +		} else {
> +			dev->set_mode(mode, dev);
> +		}
> +
>  		dev->mode = mode;
> 
>  		/*
> @@ -448,8 +457,14 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq)
>  	if (dev->mode == CLOCK_EVT_MODE_ONESHOT)
>  		return clockevents_program_event(dev, dev->next_event, false);
> 
> -	if (dev->mode == CLOCK_EVT_MODE_PERIODIC)
> -		dev->set_mode(CLOCK_EVT_MODE_PERIODIC, dev);
> +	if (dev->mode == CLOCK_EVT_MODE_PERIODIC) {
> +		/* Shouldn't fail while switching to PERIODIC MODE */
> +		if (dev->set_dev_mode)
> +			WARN_ON_ONCE(dev->set_dev_mode(CLOCK_EVT_MODE_PERIODIC,
> +						       dev));
> +		else
> +			dev->set_mode(CLOCK_EVT_MODE_PERIODIC, dev);
> +	}
> 
>  	return 0;
>  }
> diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
> index 61ed862cdd37..957a04951ef0 100644
> --- a/kernel/time/timer_list.c
> +++ b/kernel/time/timer_list.c
> @@ -229,7 +229,10 @@ print_tickdevice(struct seq_file *m, struct tick_device *td, int cpu)
>  	SEQ_printf(m, "\n");
> 
>  	SEQ_printf(m, " set_mode:       ");
> -	print_name_offset(m, dev->set_mode);
> +	if (dev->set_dev_mode)
> +		print_name_offset(m, dev->set_dev_mode);
> +	else
> +		print_name_offset(m, dev->set_mode);
>  	SEQ_printf(m, "\n");
> 
>  	SEQ_printf(m, " event_handler:  ");
> 
Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>


  reply	other threads:[~2014-12-10  3:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09 22:03 [PATCH 0/2] clockevents: introduce ->set_dev_mode() and convert a few drivers Kevin Hilman
2014-12-09 22:03 ` Kevin Hilman
2014-12-09 22:03 ` [PATCH 1/2] clockevents: introduce ->set_dev_mode() which can return error Kevin Hilman
2014-12-09 22:03   ` Kevin Hilman
2014-12-10  3:27   ` Preeti U Murthy [this message]
2014-12-10  3:27     ` Preeti U Murthy
2015-01-23 11:57   ` Thomas Gleixner
2015-01-23 11:57     ` Thomas Gleixner
2015-01-25 13:57     ` Viresh Kumar
2015-01-25 13:57       ` Viresh Kumar
2015-01-25 15:03       ` Thomas Gleixner
2015-01-25 15:03         ` Thomas Gleixner
2014-12-09 22:03 ` [PATCH 2/2] clockevents: migrate some drivers to new ->set_dev_mode() Kevin Hilman
2014-12-09 22:03   ` Kevin Hilman
2015-01-15 18:41 ` [PATCH 0/2] clockevents: introduce ->set_dev_mode() and convert a few drivers Kevin Hilman
2015-01-15 18:41   ` Kevin Hilman
2015-01-15 22:25   ` Thomas Gleixner
2015-01-15 22:25     ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2014-11-19 18:39 Kevin Hilman
2014-11-19 18:39 ` [PATCH 1/2] clockevents: introduce ->set_dev_mode() which can return error Kevin Hilman
2014-11-19 18:39   ` Kevin Hilman
2014-11-20  4:04   ` Preeti U Murthy
2014-11-20  4:04     ` Preeti U Murthy
2014-07-04  4:21 [PATCH 0/2] clockevents: introduce ->set_dev_mode() and convert a few drivers Kevin Hilman
2014-07-04  4:21 ` [PATCH 1/2] clockevents: introduce ->set_dev_mode() which can return error Kevin Hilman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5487BD8B.5060903@linux.vnet.ibm.com \
    --to=preeti@linux.vnet.ibm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.