From patchwork Wed Dec 9 05:29:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 341554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 449B6C4361B for ; Wed, 9 Dec 2020 05:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF91D23B4B for ; Wed, 9 Dec 2020 05:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727681AbgLIFa4 (ORCPT ); Wed, 9 Dec 2020 00:30:56 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35970 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727668AbgLIFaw (ORCPT ); Wed, 9 Dec 2020 00:30:52 -0500 Received: by mail-pf1-f193.google.com with SMTP id b26so280558pfi.3; Tue, 08 Dec 2020 21:30:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XMPNBLC7erCmsHGfeP6BsbcItk7t2bKK4kjtfKvNqKQ=; b=k4LWi682jmdJgVLlyU2wTm3E6tggMd5ZsJNsbxEtinqNcTZhjo4w4EjU6bNOMq2Yph qnTeVA6XdVcYil1d6nNqkrN5usyhTsHXBy3k79qv2+ZeZiZk16dPUXZ0B8fTnAIj6eFP g+1cWh0r+jeQ7H1hnrDtn0pCwn0rqNpT8T+01KEi29urLqoozBBu9qT4XmVJh6adaVB6 OtZ5wj86RgU2pGIJvOhcF1pv3mKZwE72ZWEZjj3p/mqdfkEP+zF9xr6nfJMRTbhCcUCc aJxBAq9CVNyFondvXPgz711a7L2Dcrhpzho3XsUYrGLD1okNF1jG97vxrQQlOhnYhGFd SKFw== X-Gm-Message-State: AOAM5318FlvHW0TZEzrjP+WqGo/Gyc11qyo5KiAAXwCrShTJlUMrhKhz lzIPABRBlHEaklcjo81KejI= X-Google-Smtp-Source: ABdhPJzf2OMDrP87HF8jRLQfCTdwfKsLZzXPguCHpomNNcnMqzIuMSJTt2cv0SKD0KtDM4c4WuOSEw== X-Received: by 2002:a63:534c:: with SMTP id t12mr531888pgl.128.1607491811226; Tue, 08 Dec 2020 21:30:11 -0800 (PST) Received: from asus.hsd1.ca.comcast.net (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id 77sm753097pfv.16.2020.12.08.21.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 21:30:10 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jens Axboe , Christoph Hellwig , Hannes Reinecke , Ming Lei , linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Bart Van Assche , Alan Stern , James Bottomley , Woody Suwalski , Can Guo , Stanley Chu , "Rafael J . Wysocki" , Stan Johnson Subject: [PATCH v5 5/8] scsi_transport_spi: Set RQF_PM for domain validation commands Date: Tue, 8 Dec 2020 21:29:48 -0800 Message-Id: <20201209052951.16136-6-bvanassche@acm.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201209052951.16136-1-bvanassche@acm.org> References: <20201209052951.16136-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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. Reviewed-by: Christoph Hellwig Reviewed-by: Jens Axboe 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 Signed-off-by: Bart Van Assche --- 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 f3d5b1bbd5aa..c37dd15d16d2 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);