From: Bart Van Assche <bvanassche@acm.org> To: "Martin K . Petersen" <martin.petersen@oracle.com> Cc: "James E . J . Bottomley" <jejb@linux.vnet.ibm.com>, Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>, Hannes Reinecke <hare@suse.de>, Ming Lei <ming.lei@redhat.com>, linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>, Alan Stern <stern@rowland.harvard.edu>, James Bottomley <James.Bottomley@HansenPartnership.com>, Woody Suwalski <terraluna977@gmail.com>, Can Guo <cang@codeaurora.org>, Stanley Chu <stanley.chu@mediatek.com>, "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>, Stan Johnson <userm57@yahoo.com> 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> (raw) In-Reply-To: <20201209052951.16136-1-bvanassche@acm.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 <hch@lst.de> Reviewed-by: Jens Axboe <axboe@kernel.dk> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Woody Suwalski <terraluna977@gmail.com> Cc: Can Guo <cang@codeaurora.org> Cc: Stanley Chu <stanley.chu@mediatek.com> Cc: Ming Lei <ming.lei@redhat.com> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Stan Johnson <userm57@yahoo.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- 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);
next prev parent reply index Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-09 5:29 [PATCH v5 0/8] Rework runtime suspend and SPI domain validation Bart Van Assche 2020-12-09 5:29 ` [PATCH v5 1/8] block: Fix a race in the runtime power management code Bart Van Assche 2020-12-09 5:29 ` [PATCH v5 2/8] block: Introduce BLK_MQ_REQ_PM Bart Van Assche 2020-12-09 6:06 ` Can Guo 2020-12-09 5:29 ` [PATCH v5 3/8] ide: Do not set the RQF_PREEMPT flag for sense requests Bart Van Assche 2020-12-09 5:29 ` [PATCH v5 4/8] ide: Mark power management requests with RQF_PM instead of RQF_PREEMPT Bart Van Assche 2020-12-09 5:29 ` Bart Van Assche [this message] 2020-12-09 7:34 ` [PATCH v5 5/8] scsi_transport_spi: Set RQF_PM for domain validation commands Hannes Reinecke 2020-12-09 5:29 ` [PATCH v5 6/8] scsi: Only process PM requests if rpm_status != RPM_ACTIVE Bart Van Assche 2020-12-09 6:06 ` Can Guo 2020-12-09 5:29 ` [PATCH v5 7/8] block: Remove RQF_PREEMPT and BLK_MQ_REQ_PREEMPT Bart Van Assche 2020-12-09 6:05 ` Can Guo 2020-12-09 5:29 ` [PATCH v5 8/8] block: Do not accept any requests while suspended Bart Van Assche 2020-12-09 6:04 ` Can Guo 2020-12-09 7:36 ` Hannes Reinecke 2020-12-09 16:44 ` [PATCH v5 0/8] Rework runtime suspend and SPI domain validation Martin K. Petersen
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=20201209052951.16136-6-bvanassche@acm.org \ --to=bvanassche@acm.org \ --cc=James.Bottomley@HansenPartnership.com \ --cc=axboe@kernel.dk \ --cc=cang@codeaurora.org \ --cc=hare@suse.de \ --cc=hch@lst.de \ --cc=jejb@linux.vnet.ibm.com \ --cc=linux-block@vger.kernel.org \ --cc=linux-scsi@vger.kernel.org \ --cc=martin.petersen@oracle.com \ --cc=ming.lei@redhat.com \ --cc=rafael.j.wysocki@intel.com \ --cc=stanley.chu@mediatek.com \ --cc=stern@rowland.harvard.edu \ --cc=terraluna977@gmail.com \ --cc=userm57@yahoo.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
Linux-Block Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \ linux-block@vger.kernel.org public-inbox-index linux-block Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block AGPL code for this site: git clone https://public-inbox.org/public-inbox.git