linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dolev Raviv <draviv@codeaurora.org>
Cc: James.Bottomley@HansenPartnership.com, hch@infradead.org,
	linux-scsi@vger.kernel.org, linux-scsi-owner@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, santoshsy@gmail.com,
	Sujit Reddy Thumma <sthumma@codeaurora.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: Re: [RFC 09/10] scsi: sd: Avoid sending medium write commands if device is write protected
Date: Tue, 19 Aug 2014 10:30:22 -0700	[thread overview]
Message-ID: <20140819173022.GA2072@infradead.org> (raw)
In-Reply-To: <1407760838-6406-10-git-send-email-draviv@codeaurora.org>

This looks reasonable to me.  Martin, and objections?

On Mon, Aug 11, 2014 at 03:40:37PM +0300, Dolev Raviv wrote:
> From: Sujit Reddy Thumma <sthumma@codeaurora.org>
> 
> The SYNCHRONIZE_CACHE command is a medium write command and hence can
> fail when the device is write protected. Avoid sending such commands by
> making sure that write-cache-enable is disabled even though the device
> claim to support it.
> 
> Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
> Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 3663e38..67282bf 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -185,7 +185,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr,
>  	if (ct < 0)
>  		return -EINVAL;
>  	rcd = ct & 0x01 ? 1 : 0;
> -	wce = ct & 0x02 ? 1 : 0;
> +	wce = (ct & 0x02) && !sdkp->write_prot ? 1 : 0;
>  
>  	if (sdkp->cache_override) {
>  		sdkp->WCE = wce;
> @@ -2493,6 +2493,10 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
>  			sdkp->DPOFUA = 0;
>  		}
>  
> +		/* No cache flush allowed for write protected devices */
> +		if (sdkp->WCE && sdkp->write_prot)
> +			sdkp->WCE = 0;
> +
>  		if (sdkp->first_scan || old_wce != sdkp->WCE ||
>  		    old_rcd != sdkp->RCD || old_dpofua != sdkp->DPOFUA)
>  			sd_printk(KERN_NOTICE, sdkp,
> -- 
> 1.8.5.2
> -- 
> QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
> of Code Aurora Forum, hosted by The Linux Foundation
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
---end quoted text---

  reply	other threads:[~2014-08-19 17:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-11 12:40 [RFC 00/10] UFS: Power managment support Dolev Raviv
2014-08-11 12:40 ` [RFC 01/10] scsi: ufs: Allow vendor specific initialization Dolev Raviv
2014-08-11 12:40 ` [RFC 02/10] scsi: ufs: Add regulator enable support Dolev Raviv
2014-08-11 12:40 ` [RFC 03/10] scsi: ufs: Add clock initialization support Dolev Raviv
2014-08-11 12:40 ` [RFC 04/10] scsi: ufs: refactor query descriptor API support Dolev Raviv
2014-08-11 12:40 ` [RFC 05/10] scsi: ufs: improve init sequence Dolev Raviv
2014-08-11 12:40 ` [RFC 06/10] scsi: ufs: Active Power Mode - configuring bActiveICCLevel Dolev Raviv
2014-08-11 12:40 ` [RFC 07/10] scsi: support well known logical units Dolev Raviv
2014-08-11 12:40 ` [RFC 08/10] scsi: ufs: introduce well known logical unit in ufs Dolev Raviv
2014-08-11 12:40 ` [RFC 09/10] scsi: sd: Avoid sending medium write commands if device is write protected Dolev Raviv
2014-08-19 17:30   ` Christoph Hellwig [this message]
2014-08-20 13:24     ` Martin K. Petersen
2014-08-19 17:55   ` Venkatesh Srinivas
2014-08-24 16:28   ` [RFC 09/10] " Christoph Hellwig
2014-08-11 12:40 ` [RFC 10/10] scsi: ufs: add UFS power management support Dolev Raviv

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=20140819173022.GA2072@infradead.org \
    --to=hch@infradead.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=draviv@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-scsi-owner@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=santoshsy@gmail.com \
    --cc=sthumma@codeaurora.org \
    /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).