From: "Marcus Haebler" <haebler@gmail.com>
To: "Tejun Heo" <htejun@gmail.com>
Cc: "Pablo Sebastian Greco" <lkml@fliagreco.com.ar>,
linux-kernel@vger.kernel.org
Subject: Re: SATA problems
Date: Wed, 21 Feb 2007 00:57:06 -0500 [thread overview]
Message-ID: <d72aa1340702202157l1932b393k36cb58ecfbe40178@mail.gmail.com> (raw)
In-Reply-To: <45DBC2CE.6040408@gmail.com>
Tejun,
thanks. In preparation of your patch I installed a vanilla 2.6.20.1
kernel on my FC6
system. Amazingly the problem went away with the vanilla(!) kernel and NCQ
is enabled at boot time (queue_depth is 31). I guess I should have
tried that kernel
earlier.
The patches you sent earlier apply w/o problems against the 2.6.20.1
vanilla kernel
which is expected. I will test drive those patches tomorrow.
BTW thanks for saving me the 'cat' on the 3 patches. ;)
Thanks,
Marcus
On 2/20/07, Tejun Heo <htejun@gmail.com> wrote:
> Marcus Haebler wrote:
> > thanks for the patches! I am on an Intel P965/ICH8R.
>
> I see. That can happen too. There was a race window where in-flight
> r/w command which left SCSI midlayer but pending on libata gets executed
> in the wrong mode. If possible, please verify that it doesn't happen
> with the patches applied. I'm attaching combined patch against v2.6.20.
>
> Thanks.
>
> --
> tejun
>
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index 667acd2..348cc02 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -308,9 +308,7 @@ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
> tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
> tf->flags |= tf_flags;
>
> - if ((dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
> - ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ &&
> - likely(tag != ATA_TAG_INTERNAL)) {
> + if (ata_ncq_enabled(dev) && likely(tag != ATA_TAG_INTERNAL)) {
> /* yay, NCQ */
> if (!lba_48_ok(block, n_block))
> return -ERANGE;
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 73902d3..ebb9185 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -945,29 +945,32 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
> struct ata_port *ap = ata_shost_to_port(sdev->host);
> struct ata_device *dev;
> unsigned long flags;
> - int max_depth;
>
> - if (queue_depth < 1)
> + if (queue_depth < 1 || queue_depth == sdev->queue_depth)
> return sdev->queue_depth;
>
> dev = ata_scsi_find_dev(ap, sdev);
> if (!dev || !ata_dev_enabled(dev))
> return sdev->queue_depth;
>
> - max_depth = min(sdev->host->can_queue, ata_id_queue_depth(dev->id));
> - max_depth = min(ATA_MAX_QUEUE - 1, max_depth);
> - if (queue_depth > max_depth)
> - queue_depth = max_depth;
> -
> - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, queue_depth);
> -
> + /* NCQ enabled? */
> spin_lock_irqsave(ap->lock, flags);
> - if (queue_depth > 1)
> - dev->flags &= ~ATA_DFLAG_NCQ_OFF;
> - else
> + dev->flags &= ~ATA_DFLAG_NCQ_OFF;
> + if (queue_depth == 1 || !ata_ncq_enabled(dev)) {
> dev->flags |= ATA_DFLAG_NCQ_OFF;
> + queue_depth = 1;
> + }
> spin_unlock_irqrestore(ap->lock, flags);
>
> + /* limit and apply queue depth */
> + queue_depth = min(queue_depth, sdev->host->can_queue);
> + queue_depth = min(queue_depth, ata_id_queue_depth(dev->id));
> + queue_depth = min(queue_depth, ATA_MAX_QUEUE - 1);
> +
> + if (sdev->queue_depth == queue_depth)
> + return -EINVAL;
> +
> + scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, queue_depth);
> return queue_depth;
> }
>
> @@ -1454,11 +1457,9 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
> static int ata_scmd_need_defer(struct ata_device *dev, int is_io)
> {
> struct ata_port *ap = dev->ap;
> + int is_ncq = is_io && ata_ncq_enabled(dev);
>
> - if (!(dev->flags & ATA_DFLAG_NCQ))
> - return 0;
> -
> - if (is_io) {
> + if (is_ncq) {
> if (!ata_tag_valid(ap->active_tag))
> return 0;
> } else {
> diff --git a/include/linux/libata.h b/include/linux/libata.h
> index 91bb8ce..4e4e365 100644
> --- a/include/linux/libata.h
> +++ b/include/linux/libata.h
> @@ -1035,6 +1035,21 @@ static inline u8 ata_chk_status(struct ata_port *ap)
> return ap->ops->check_status(ap);
> }
>
> +/**
> + * ata_ncq_enabled - Test whether NCQ is enabled
> + * @dev: ATA device to test for
> + *
> + * LOCKING:
> + * spin_lock_irqsave(host lock)
> + *
> + * RETURNS:
> + * 1 if NCQ is enabled for @dev, 0 otherwise.
> + */
> +static inline int ata_ncq_enabled(struct ata_device *dev)
> +{
> + return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
> + ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
> +}
>
> /**
> * ata_pause - Flush writes and pause 400 nanoseconds.
>
>
next prev parent reply other threads:[~2007-02-21 5:57 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-02 14:08 Pablo Sebastian Greco
2007-01-03 12:20 ` Tejun Heo
2007-01-03 15:08 ` Pablo Sebastian Greco
2007-01-04 5:02 ` Tejun Heo
2007-01-04 13:17 ` Pablo Sebastian Greco
2007-01-05 3:15 ` Pablo Sebastian Greco
2007-01-08 2:23 ` Tejun Heo
2007-01-08 2:49 ` Jeff Garzik
2007-01-08 12:22 ` Pablo Sebastian Greco
2007-01-09 22:58 ` Pablo Sebastian Greco
2007-01-10 1:55 ` Tejun Heo
2007-01-23 17:45 ` Pablo Sebastian Greco
2007-01-24 1:54 ` Tejun Heo
2007-02-17 12:49 ` Marcus Haebler
2007-02-17 16:47 ` Pablo Sebastian Greco
2007-02-20 14:35 ` Tejun Heo
2007-02-20 16:24 ` Pablo Sebastian Greco
2007-02-21 3:08 ` Tejun Heo
2007-02-21 15:18 ` Pablo Sebastian Greco
2007-02-21 0:55 ` Marcus Haebler
2007-02-21 3:55 ` Tejun Heo
2007-02-21 5:57 ` Marcus Haebler [this message]
2007-02-21 6:24 ` Marcus Haebler
2007-02-21 7:25 ` Paul Rolland
2007-02-21 13:04 ` Marcus Haebler
[not found] <8vX5T-4hg-5@gated-at.bofh.it>
[not found] ` <8w0n1-15u-27@gated-at.bofh.it>
2007-06-14 16:58 ` Nigel Kukard
2007-06-14 17:33 ` Jeff Garzik
2007-06-18 8:05 ` Nigel Kukard
-- strict thread matches above, loose matches on Subject: below --
2007-06-14 12:36 Nigel Kukard
2007-06-14 16:21 ` Jeff Garzik
2007-06-14 18:28 ` Dave Jones
2007-06-18 20:07 ` Dave Jones
2007-06-19 4:57 ` Nigel Kukard
2007-08-30 9:24 ` Nigel Kukard
2007-09-10 9:02 ` Andrew Morton
2007-09-13 8:55 ` Tejun Heo
2004-02-11 17:52 SATA Problems Dott. Surricani
2004-02-11 18:08 ` Armen Kaleshian
[not found] ` <402A72F0.9030005@surricani.cjb.net>
2004-02-11 18:25 ` Armen Kaleshian
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=d72aa1340702202157l1932b393k36cb58ecfbe40178@mail.gmail.com \
--to=haebler@gmail.com \
--cc=htejun@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@fliagreco.com.ar \
/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
all inboxes | Powered by JetHome®