mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Eran Tromer <eran@tromer.org>
Cc: Jeff Garzik <jgarzik@pobox.com>,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mark Lord <mlord@pobox.com>
Subject: Re: [patch] libata: return sense data in HDIO_DRIVE_CMD ioctl
Date: Thu, 28 Sep 2006 10:45:29 +0900	[thread overview]
Message-ID: <20060928014529.GF25800@htj.dyndns.org> (raw)
In-Reply-To: <451AA16F.1080704@tromer.org>

Hello, Eran Tromer.

On Wed, Sep 27, 2006 at 07:06:07PM +0300, Eran Tromer wrote:
> > hdparm -C says the same thing for my drive.  I think it's safe to
> > ignore.  Hmmm... it needs to be tracked down.  Maybe some problem in
> > HDIO ioctl implementation in libata.
> 
> Yes, and fixed by this patch.

Great.  Things look good at the first glance.  Just a few comments.

> @@ -210,18 +214,46 @@ int ata_cmd_ioctl(struct scsi_device *sc
> 
>  	/* Good values for timeout and retries?  Values below
>  	   from scsi_ioctl_send_command() for default case... */
> -	if (scsi_execute_req(scsidev, scsi_cmd, data_dir, argbuf, argsize,
> -			     &sshdr, (10*HZ), 5)) {
> +	cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
> +	                          sensebuf, (10*HZ), 5, 0);
> +
> +	if ((cmd_result>>24) == DRIVER_SENSE) {   /* sense data available */

driver_byte() seems more appropriate.

> +		u8 *desc = sensebuf + 8;
> +		cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
> +
> +		/* If we set cc then ATA pass-through will cause a
> +		 * check condition even if no error. Filter that. */
> +		if (cmd_result & SAM_STAT_CHECK_CONDITION) {
> +			struct scsi_sense_hdr sshdr;
> +			scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE,
> +			                      &sshdr);
> +			if (sshdr.sense_key==0 &&
> +			    sshdr.asc==0 && sshdr.ascq==0)
> +				cmd_result &= ~SAM_STAT_CHECK_CONDITION;
> +		}
> +
> +		/* Send userspace a few ATA registers (same as drivers/ide) */
> +		if (sensebuf[0] == 0x72 &&     /* format is "descriptor" */
> +		    desc[0] == 0x09 ) {        /* code is "ATA Descriptor" */
> +			args[0] = desc[13];    /* status */
> +			args[1] = desc[3];     /* error */
> +			args[2] = desc[5];     /* sector count (0:7) */
> +			if (copy_to_user(arg, args, sizeof(args)))
> +				rc = -EFAULT;
> +		}
> +	}
> +
> +
> +	if (cmd_result) {

I wonder whether we need to fake default error ATA regsiters here.
Anyways, it's unrelated to this patch.

>  		rc = -EIO;
>  		goto error;
>  	}
> 
> -	/* Need code to retrieve data from check condition? */
> -
>  	if ((argbuf)
>  	 && copy_to_user(arg + sizeof(args), argbuf, argsize))
>  		rc = -EFAULT;
>  error:
> +	kfree(sensebuf);
>  	kfree(argbuf);
>  	return rc;

Acked-by: Tejun Heo <htejun@gmail.com>

-- 
tejun

      reply	other threads:[~2006-09-28  1:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-27 16:06 Eran Tromer
2006-09-28  1:45 ` Tejun Heo [this message]

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=20060928014529.GF25800@htj.dyndns.org \
    --to=htejun@gmail.com \
    --cc=eran@tromer.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlord@pobox.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
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

Powered by JetHome