mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Karol Wachowski <karol.wachowski@linux.intel.com>
To: Alexander Usyskin <alexander.usyskin@intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Menachem Adin <menachem.adin@intel.com>,
	Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
Subject: Re: [PATCH char-misc-next v3 1/4] issei: save power_down flag while processing event
Date: Thu, 19 Nov 2026 10:09:21 +0100	[thread overview]
Message-ID: <720ac744-2f0e-4b46-a28e-aa635079b45d@linux.intel.com> (raw)
In-Reply-To: <20261111-issei_pm_and_itf-v3-1-4f4f6d626ff3@intel.com>

On 11-Nov-26 8:40, Alexander Usyskin wrote:
> Change in power_down flag may confuse event thread.
> Save flag status at the first available moment and
> work according to saved value.
> 
> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
> ---
>   drivers/misc/issei/main.c | 22 ++++++++++++----------
>   1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/misc/issei/main.c b/drivers/misc/issei/main.c
> index 5987fb340250..8aaf2d47392b 100644
> --- a/drivers/misc/issei/main.c
> +++ b/drivers/misc/issei/main.c
> @@ -24,7 +24,7 @@ static void issei_rst_state_set(struct issei_device *idev, enum issei_rst_state
>   		wake_up(&idev->wait_rst_state);
>   }
>   
> -static int issei_reset(struct issei_device *idev)
> +static int issei_reset(struct issei_device *idev, bool power_down)
>   {
>   	int ret;
>   
> @@ -34,14 +34,14 @@ static int issei_reset(struct issei_device *idev)
>   	issei_fw_cl_remove_all(idev);
>   	/* No need to check for overflow here, the counter is used only for info */
>   	idev->all_reset_count++;
> -	ret = idev->ops->hw_reset(idev, !idev->power_down);
> +	ret = idev->ops->hw_reset(idev, !power_down);
>   	issei_dmam_setup(idev);
>   	if (ret) {
>   		dev_err(&idev->dev, "hw_reset failed ret = %d\n", ret);
>   		return ret;
>   	}
>   
> -	if (idev->power_down) {
> +	if (power_down) {
>   		dev_dbg(&idev->dev, "powering down: end of reset\n");
>   		issei_rst_state_set(idev, ISSEI_RST_STATE_DISABLED);
>   		return -ENODEV;
> @@ -87,24 +87,26 @@ static int issei_process_thread(void *_dev)
>   {
>   	long timeout, old_timeout = MAX_SCHEDULE_TIMEOUT;
>   	struct issei_device *idev = _dev;
> +	bool power_down;
>   	int ret;
>   
>   	while (!kthread_should_stop()) {
>   		dev_dbg(&idev->dev, "process_work in %d\n", idev->rst_state);
> +		WRITE_ONCE(idev->has_data, false);
> +		power_down = idev->power_down; /* to save state */
>   		if (!idev->ops->hw_is_ready(idev) && idev->rst_state > ISSEI_RST_STATE_HW_READY) {
> -			if (!idev->power_down)
> +			if (!power_down)
>   				dev_dbg(&idev->dev, "HW not ready, resetting\n");
>   			idev->rst_state = ISSEI_RST_STATE_INIT;
>   		}
> -		if (idev->power_down)
> +		if (power_down)
>   			idev->rst_state = ISSEI_RST_STATE_INIT;
> -		WRITE_ONCE(idev->has_data, false);
>   		dev_dbg(&idev->dev, "reset_step in %d\n", idev->rst_state);
>   		timeout = MAX_SCHEDULE_TIMEOUT;
>   		ret = 0;
>   		switch (idev->rst_state) {
>   		case ISSEI_RST_STATE_DISABLED:
> -			if (idev->power_down) {
> +			if (power_down) {
>   				dev_dbg(&idev->dev, "Interrupt in power down?\n");
>   				break;
>   			}
> @@ -115,7 +117,7 @@ static int issei_process_thread(void *_dev)
>   			idev->ops->irq_clear(idev);
>   			idev->ops->irq_sync(idev);
>   
> -			if (!idev->power_down) {
> +			if (!power_down) {
>   				idev->reset_count++;
>   				if (idev->reset_count > ISSEI_MAX_CONSEC_RESET) {
>   					dev_err(&idev->dev, "reset: reached maximal consecutive resets: disabling the device\n");
> @@ -124,8 +126,8 @@ static int issei_process_thread(void *_dev)
>   				}
>   			}
>   
> -			ret = issei_reset(idev);
> -			if (idev->power_down) {
> +			ret = issei_reset(idev, power_down);
> +			if (power_down) {
>   				dev_dbg(&idev->dev, "Powering down\n");
>   				return 0;
>   			}
> 

Reviewed-by: Karol Wachowski <karol.wachowski@linux.intel.com>


  reply	other threads:[~2026-11-19  9:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  7:40 [PATCH char-misc-next v3 0/4] issei: runtime power management, dma and in-kernel interface Alexander Usyskin
2026-11-11  7:40 ` [PATCH char-misc-next v3 1/4] issei: save power_down flag while processing event Alexander Usyskin
2026-11-19  9:09   ` Karol Wachowski [this message]
2026-11-11  7:40 ` [PATCH char-misc-next v3 2/4] issei: add runtime pm Alexander Usyskin
2026-11-19  9:11   ` Karol Wachowski
2026-11-11  7:40 ` [PATCH char-misc-next v3 3/4] issei: host_client: add dma allocation support Alexander Usyskin
2026-11-19  9:09   ` Karol Wachowski
2026-11-11  7:40 ` [PATCH char-misc-next v3 4/4] issei: add driver to driver interface Alexander Usyskin
2026-11-19  9:10   ` Karol Wachowski

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=720ac744-2f0e-4b46-a28e-aa635079b45d@linux.intel.com \
    --to=karol.wachowski@linux.intel.com \
    --cc=alexander.usyskin@intel.com \
    --cc=andrzej.kacprowski@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menachem.adin@intel.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®