linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Martin Kepplinger <martin.kepplinger@puri.sm>
Cc: jejb@linux.ibm.com, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-scsi@vger.kernel.org,
	martin.petersen@oracle.com, stern@rowland.harvard.edu
Subject: Re: [PATCH v4 2/3] scsi: sd: send REQUEST SENSE for BLIST_MEDIA_CHANGE devices in runtime_resume()
Date: Tue, 29 Jun 2021 21:18:34 -0700	[thread overview]
Message-ID: <37a8e36c-73fd-b8a7-0175-ce6613efc043@acm.org> (raw)
In-Reply-To: <20210628133412.1172068-3-martin.kepplinger@puri.sm>

On 6/28/21 6:34 AM, Martin Kepplinger wrote:
> +static int sd_resume_runtime(struct device *dev)
> +{
> +	struct scsi_disk *sdkp = dev_get_drvdata(dev);
> +	struct scsi_device *sdp;
> +	int timeout, retries, res;
> +	struct scsi_sense_hdr my_sshdr;

Since the sense data is ignored, consider removing the "my_sshdr"
declaration and passing NULL as sense pointer to scsi_execute().

> +	if (!sdkp)	/* E.g.: runtime resume at the start of sd_probe() */
> +		return 0;

Are you sure that this code is necessary? There is an
scsi_autopm_get_device(sdp) call at the start of sd_probe() and
scsi_autopm_put_device(sdp) call at the end of sd_probe(). In other
words, no runtime suspend will happen between the
device_initialize(&sdkp->dev) call in sd_probe() and the
dev_set_drvdata(dev, sdkp) call in the same function.

> +	if (sdp->sdev_bflags & BLIST_MEDIA_CHANGE) {
> +		for (retries = 3; retries > 0; --retries) {
> +			unsigned char cmd[10] = { 0 };
> +
> +			cmd[0] = REQUEST_SENSE;

Please define the CDB as follows:

	static const u8 cmd[10] = { REQUEST_SENSE };

> +			/*
> +			 * Leave the rest of the command zero to indicate
> +			 * flush everything.
> +			 */

Shouldn't this comment appear above the CDB definition? Also, what does
"flush everything" mean? According to SPC sense data is discarded from
the device while processing REQUEST SENSE, no matter what the value of
the ALLOCATION LENGTH parameter in that command is. From SPC-6: "the
REQUEST SENSE command with any allocation length clears the sense data."

> +			res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL,
> +					   &my_sshdr, timeout,
> +					   sdkp->max_retries, 0, RQF_PM, NULL);

Only one level of retries please. Can sdkp->max_retries be changed into 1?

Thanks,

Bart.

  reply	other threads:[~2021-06-30  4:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 13:34 [PATCH v4 0/3] fix runtime PM for SD card readers Martin Kepplinger
2021-06-28 13:34 ` [PATCH v4 1/3] scsi: devinfo: add new flag BLIST_MEDIA_CHANGE Martin Kepplinger
2021-06-30  4:20   ` Bart Van Assche
2021-06-28 13:34 ` [PATCH v4 2/3] scsi: sd: send REQUEST SENSE for BLIST_MEDIA_CHANGE devices in runtime_resume() Martin Kepplinger
2021-06-30  4:18   ` Bart Van Assche [this message]
2021-06-28 13:34 ` [PATCH v4 3/3] scsi: devinfo: add BLIST_MEDIA_CHANGE for Ultra HS-SD/MMC usb cardreaders Martin Kepplinger
2021-06-30  4:20   ` Bart Van Assche

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=37a8e36c-73fd-b8a7-0175-ce6613efc043@acm.org \
    --to=bvanassche@acm.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.kepplinger@puri.sm \
    --cc=martin.petersen@oracle.com \
    --cc=stern@rowland.harvard.edu \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).