Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2825584pxb; Mon, 11 Jan 2021 22:27:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6TliFzlcoFBUnbAXFAmlpxocsKfhiZflVAqK3l61SQngSOwg0Sr7h2o6oNsSPfT4FAYO3 X-Received: by 2002:a17:906:259a:: with SMTP id m26mr2098239ejb.399.1610432851749; Mon, 11 Jan 2021 22:27:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610432851; cv=none; d=google.com; s=arc-20160816; b=dycxV4y1HZe+4GyJXeGzMLi/pGROpEdZJ7OsODqLdA6fObhNnsc2zxA1inJLa8+9Ww KkvkfpL/23Zo3J92mgEoLoARUR8CLfsjo8u74PscYaol8AqR1M9RVcCMZWziv+q1mWeM gKvYrPNkWb7nND/0YUwXIIUT/twYsyxaF2KPlgXllnj+sA/y0+Nz72/APfOs76aQIS8+ lcz0NITy2JQleFTh8y6asTQrsBd899FNXRES1b/lgT0P7pbE9Ejy3kZ8il+Ik5W/3Rlu XMEUA/+DozNK38uVaPq/1Io6U/y1lvsc5LeKnkcAh+RiMqFyOmao/D3uVpZTURlQcmGI M0Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dsQwRpPofcAy4RPeOKAsMgVo4YLUh7qltkmjNeWujjc=; b=n3vjrwlHe8M+z8b23itHeVwiKxaOE1pn9t3rZBDLgiXlKlvgIE0exNFCJ7mWGdF8sA /tvyt311ZUnA4PIpCRWMTk/2EzM04bxgWRyfSZYVE53+ox36Ek5C6blDBu1bPC7ZO9N9 +9VMWH72PGFm2TBRNOc8m9oWaRkNdaqy+P4Elnmo5/opYshN5utKtIOYBLMOozmPsRcU MThrLAPEp8c/W+DWd8AoIDiT/wV35k01wPqu7v7DM4X5sjRdJ3f/EiucPbcH7rccJGAV sD38rxFM21+Z9XRQJiaqSzBMG9fl0wPjUsMHArGi8xDIOaU6TrNDnSqGHfYCG73eK2h1 f7mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=up2xrLEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si855965edw.463.2021.01.11.22.27.07; Mon, 11 Jan 2021 22:27:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=up2xrLEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388215AbhAKNyf (ORCPT + 99 others); Mon, 11 Jan 2021 08:54:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:54992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730637AbhAKNHv (ORCPT ); Mon, 11 Jan 2021 08:07:51 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E9B8C225AC; Mon, 11 Jan 2021 13:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370455; bh=YLGxne2Z27dnFk+C+c83Jkj5l1wv4USSGsKiDZy/V94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=up2xrLEtg3lSSgeAtmxiAkMH6GNDeZJoIMHYu2o8UkdjG1/jaq9612Xyn7a2Tf5V+ PvXrsz7j1QfFnJXUWLwFc8Nd3laHl+k2Z935RKP2RTr0uzccAHQzIb04rT3EHd/QA4 4ow8dGDMQHi3CTeP1vQGfPaf/bc274I/1mnjDVDs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , James Bottomley , Woody Suwalski , Can Guo , Stanley Chu , Ming Lei , "Rafael J. Wysocki" , Stan Johnson , Christoph Hellwig , Jens Axboe , Hannes Reinecke , Bart Van Assche , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 06/77] scsi: scsi_transport_spi: Set RQF_PM for domain validation commands Date: Mon, 11 Jan 2021 14:01:15 +0100 Message-Id: <20210111130036.711898511@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130036.414620026@linuxfoundation.org> References: <20210111130036.414620026@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bart Van Assche [ Upstream commit cfefd9f8240a7b9fdd96fcd54cb029870b6d8d88 ] Disable runtime power management during domain validation. Since a later patch removes RQF_PREEMPT, set RQF_PM for domain validation commands such that these are executed in the quiesced SCSI device state. Link: https://lore.kernel.org/r/20201209052951.16136-6-bvanassche@acm.org Cc: Alan Stern Cc: James Bottomley Cc: Woody Suwalski Cc: Can Guo Cc: Stanley Chu Cc: Ming Lei Cc: Rafael J. Wysocki Cc: Stan Johnson Reviewed-by: Christoph Hellwig Reviewed-by: Jens Axboe Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi_transport_spi.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 69213842e63e0..efb9c3d902133 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -130,12 +130,16 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd, sshdr = &sshdr_tmp; for(i = 0; i < DV_RETRIES; i++) { + /* + * The purpose of the RQF_PM flag below is to bypass the + * SDEV_QUIESCE state. + */ result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense, sshdr, DV_TIMEOUT, /* retries */ 1, REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER, - 0, NULL); + RQF_PM, NULL); if (driver_byte(result) != DRIVER_SENSE || sshdr->sense_key != UNIT_ATTENTION) break; @@ -1018,23 +1022,26 @@ spi_dv_device(struct scsi_device *sdev) */ lock_system_sleep(); + if (scsi_autopm_get_device(sdev)) + goto unlock_system_sleep; + if (unlikely(spi_dv_in_progress(starget))) - goto unlock; + goto put_autopm; if (unlikely(scsi_device_get(sdev))) - goto unlock; + goto put_autopm; spi_dv_in_progress(starget) = 1; buffer = kzalloc(len, GFP_KERNEL); if (unlikely(!buffer)) - goto out_put; + goto put_sdev; /* We need to verify that the actual device will quiesce; the * later target quiesce is just a nice to have */ if (unlikely(scsi_device_quiesce(sdev))) - goto out_free; + goto free_buffer; scsi_target_quiesce(starget); @@ -1054,12 +1061,16 @@ spi_dv_device(struct scsi_device *sdev) spi_initial_dv(starget) = 1; - out_free: +free_buffer: kfree(buffer); - out_put: + +put_sdev: spi_dv_in_progress(starget) = 0; scsi_device_put(sdev); -unlock: +put_autopm: + scsi_autopm_put_device(sdev); + +unlock_system_sleep: unlock_system_sleep(); } EXPORT_SYMBOL(spi_dv_device); -- 2.27.0