Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2275997pxb; Mon, 11 Jan 2021 05:50:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYHeT0v46Y27/V0uN0qEZnE4RCCxBoMfhfsSS5EbX/68fSgCgJA/C8PAMHD6Iph9fSz3kw X-Received: by 2002:a17:906:cec7:: with SMTP id si7mr10562291ejb.123.1610373028259; Mon, 11 Jan 2021 05:50:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610373028; cv=none; d=google.com; s=arc-20160816; b=mwAnOoRl+wyWzns4ugcHsaHRUvwEcYyAxmVjmWwuJ5BQWLOH52mAU+xCP8/d8OURUG ty5xDyyzPmKEGaX+wdPGyY+ndiFrn88PhJYSis9Fcy7rWS8i2g/OuKoc+l6iwJyg94c1 AoblHGdto5uU1Wlet+lxINTrtWG4KL9S2YjL4wwqOjtLAqVrlnKmtqnzSCqWxdbsHFSR +65CUIW0/42/KfpvBtB3liUcvZlO5rTgcJJWHWXxEhCejHUIbN6cBp7pC10OQwRgTLHW hHLaXZLJIz6MhjWoVdAqui815OHFtgMXbHKRi9vVm7JYMoSu5aZ4phnFj3etFW+iEr52 Fk1w== 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=gRw7XQKeQAEisK2xlY37oOjw+6CzvB5nBowMuslFvME=; b=pgdx0QIWPRKTJQnlu4a8Ec3eOLi5jGuLVeA6Y86I57DwlJFmYObk3Xzx85wSdigDsE Dcl4JogGG3Ni4hEbiA4Y5/qcTM9kCB1i+M18gd1Wew+hMl83edekydeph0GeCwRoXtBZ zA8+CMbTW0Qf0jxmGG7G5RSeDNxmHpO2Tt80kBga0SU5Nn6NSH81zLj/7gmfsdV/BqGP exBLF7nouXCAXDLIGqur5PFuCLEaLuQpUxGK5qpb0o4KxTbspk0HXGhKt4hn+YBdddv5 LA//jU1j2q/S8ikBAbkfFdRMIXBOqlH6wPTY74/QHwWNpqeiksJjDZ9pKccJXbSw77m5 TdYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WlnhLItE; 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 i2si6823171edv.606.2021.01.11.05.50.04; Mon, 11 Jan 2021 05:50:28 -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=WlnhLItE; 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 S1730899AbhAKNqr (ORCPT + 99 others); Mon, 11 Jan 2021 08:46:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:57186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731250AbhAKNKo (ORCPT ); Mon, 11 Jan 2021 08:10:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8FB4E2253A; Mon, 11 Jan 2021 13:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370629; bh=xoTRx8qQQtnSaYwMqIVpCPfEi1lceBrcYZvQ/URSaLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WlnhLItEkCpkEx29Jljb0QMw4uzRolY2+fwqCwsf1lRIBM9eLHa+DIMbbnxMPpXRs Wm/SWe3XEk0wJlly+EszQ/nGOjFlNeHTsZvgIYiiUY/GX0D1y+A9Nwieyomva1Yw9D vhjghi43T+TqmijDdMGJ81TNC0mgV1IcNF5zIUlI= 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 5.4 05/92] scsi: scsi_transport_spi: Set RQF_PM for domain validation commands Date: Mon, 11 Jan 2021 14:01:09 +0100 Message-Id: <20210111130039.422834627@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@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 f3d5b1bbd5aa7..c37dd15d16d24 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -117,12 +117,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; @@ -1005,23 +1009,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); @@ -1041,12 +1048,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