mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>,
	rafael.j.wysocki@intel.com, lenb@kernel.org
Cc: tangmeng <tangmeng@uniontech.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Petr Mladek <pmladek@suse.com>,
	YueHaibing <yuehaibing@huawei.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] kernel/reboot: Add SYS_OFF_MODE_RESTART_PREPARE mode
Date: Tue, 13 Sep 2022 18:13:56 +0300	[thread overview]
Message-ID: <a88168af-e072-2af6-fca4-0472d3277f68@collabora.com> (raw)
In-Reply-To: <20220913062042.1977790-1-kai.heng.feng@canonical.com>

On 9/13/22 09:20, Kai-Heng Feng wrote:
> Add SYS_OFF_MODE_RESTART_PREPARE callbacks can be invoked before system
> restart.
> 
> This is a preparation for next patch.
> 
> Suggested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
> v3:
>  - New patch.
> 
>  include/linux/reboot.h |  8 ++++++++
>  kernel/reboot.c        | 17 +++++++++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/include/linux/reboot.h b/include/linux/reboot.h
> index e5d9ef886179c..ba87cdef2335a 100644
> --- a/include/linux/reboot.h
> +++ b/include/linux/reboot.h
> @@ -105,6 +105,14 @@ enum sys_off_mode {
>  	 */
>  	SYS_OFF_MODE_POWER_OFF,
>  
> +	/**
> +	 * @SYS_OFF_MODE_RESTART_PREPARE:
> +	 *
> +	 * Handlers prepare system to be powered off. Handlers are

s/powered off/restarted/

> +	 * allowed to sleep.
> +	 */
> +	SYS_OFF_MODE_RESTART_PREPARE,
> +
>  	/**
>  	 * @SYS_OFF_MODE_RESTART:
>  	 *
> diff --git a/kernel/reboot.c b/kernel/reboot.c
> index 3c35445bf5ad3..3bba88c7ffc6b 100644
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -243,6 +243,17 @@ void migrate_to_reboot_cpu(void)
>  	set_cpus_allowed_ptr(current, cpumask_of(cpu));
>  }
>  
> +/*
> + *	Notifier list for kernel code which wants to be called
> + *	to prepare system for restart.
> + */
> +static BLOCKING_NOTIFIER_HEAD(restart_prep_handler_list);
> +
> +static void do_kernel_restart_prepare(void)
> +{
> +	blocking_notifier_call_chain(&restart_prep_handler_list, 0, NULL);
> +}
> +
>  /**
>   *	kernel_restart - reboot the system
>   *	@cmd: pointer to buffer containing command to execute for restart
> @@ -254,6 +265,7 @@ void migrate_to_reboot_cpu(void)
>  void kernel_restart(char *cmd)
>  {
>  	kernel_restart_prepare(cmd);
> +	do_kernel_restart_prepare();
>  	migrate_to_reboot_cpu();
>  	syscore_shutdown();
>  	if (!cmd)
> @@ -396,6 +408,11 @@ register_sys_off_handler(enum sys_off_mode mode,
>  		handler->list = &power_off_handler_list;
>  		break;
>  
> +	case SYS_OFF_MODE_RESTART_PREPARE:
> +		handler->list = &restart_prep_handler_list;
> +		handler->blocking = true;
> +		break;
> +
>  	case SYS_OFF_MODE_RESTART:
>  		handler->list = &restart_handler_list;
>  		break;

With the above comment addressed:

Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>

-- 
Best regards,
Dmitry


  parent reply	other threads:[~2022-09-13 16:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13  6:20 Kai-Heng Feng
2022-09-13  6:20 ` [PATCH v3 2/2] PM: ACPI: reboot: Reinstate S5 for reboot Kai-Heng Feng
2022-09-13 15:17   ` Dmitry Osipenko
2022-09-16  0:03     ` Kai-Heng Feng
2022-09-13 15:13 ` Dmitry Osipenko [this message]
2022-09-16  0:03   ` [PATCH v3 1/2] kernel/reboot: Add SYS_OFF_MODE_RESTART_PREPARE mode Kai-Heng Feng

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=a88168af-e072-2af6-fca4-0472d3277f68@collabora.com \
    --to=dmitry.osipenko@collabora.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=pmladek@suse.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tangmeng@uniontech.com \
    --cc=yuehaibing@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®