Re: [PATCH v1] scsi: core: pair EH runtime PM get and put

Bart Van Assche <[email protected]>
Newsgroups org.kernel.vger.linux-scsi,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 6/23/26 12:44 AM, Hongjie Fang wrote:
> @@ -2383,12 +2384,16 @@ int scsi_error_handler(void *data)
>   		 * what we need to do to get it up and online again (if we can).
>   		 * If we fail, we end up taking the thing offline.
>   		 */
> -		if (!shost->eh_noresume && scsi_autopm_get_host(shost) != 0) {
> -			SCSI_LOG_ERROR_RECOVERY(1,
> -				shost_printk(KERN_ERR, shost,
> -					     "scsi_eh_%d: unable to autoresume\n",
> -					     shost->host_no));
> -			continue;
> +		autopm_put = false;
> +		if (!shost->eh_noresume) {
> +			if (scsi_autopm_get_host(shost) != 0) {
> +				SCSI_LOG_ERROR_RECOVERY(1,
> +					shost_printk(KERN_ERR, shost,
> +						     "scsi_eh_%d: unable to autoresume\n",
> +						     shost->host_no));
> +				continue;
> +			}
> +			autopm_put = true;
>   		}
>   
>   		if (shost->transportt->eh_strategy_handler)
> @@ -2407,7 +2412,7 @@ int scsi_error_handler(void *data)
>   		 * which are still online.
>   		 */
>   		scsi_restart_operations(shost);
> -		if (!shost->eh_noresume)
> +		if (autopm_put)
>   			scsi_autopm_put_host(shost);
>   	}
>   	__set_current_state(TASK_RUNNING);

Please capture the value of shost->eh_noresume in a local variable such 
that concurrent changes of shost->eh_noresume can't break the above
code.

Thanks,

Bart.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.