PDA

View Full Version : NCQ: how do I tell if its on / turning it on


johannlo
2007-05-21, 04:21 AM CDT
I am running a Gigabyte GA965P-S3 with 3x SATA drives, all NCQ capable. BIOS settings for the Intel ICH8/Jmicron363 controllers is in AHCI mode.

When I boot up I get lines like this suggesting that I do have NCQ and fedora sees it

ata1: SATA max UDMA/133 cmd 0xB400 ctl 0xB802 bmdma 0xC400 irq 17
ata2: SATA max UDMA/133 cmd 0xBC00 ctl 0xC002 bmdma 0xC408 irq 17
scsi0 : ata_piix
ata1.00: ATA-7, max UDMA/133, 625140335 sectors: LBA48 NCQ (depth 0/32)
ata1.00: ata1: dev 0 multi count 16
ata1.00: configured for UDMA/133
scsi1 : ata_piix
ata2.00: ATA-7, max UDMA/133, 625142448 sectors: LBA48 NCQ (depth 0/32)
ata2.00: ata2: dev 0 multi count 16
ata2.00: configured for UDMA/133
scsi 0:0:0:0: Direct-Access ATA ST3320620AS 3.AA PQ: 0 ANSI: 5
SCSI device sda: 625140335 512-byte hdwr sectors (320072 MB)
sda: Write Protect is off
sda: Mode Sense: 00 3a 00 00
SCSI device sda: write cache: enabled, read cache: enabled, doesn't support DPO or FUA
SCSI device sda: 625140335 512-byte hdwr sectors (320072 MB)
sda: Write Protect is off
sda: Mode Sense: 00 3a 00 00
SCSI device sda: write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sda: sda1
sd 0:0:0:0: Attached scsi disk sda
scsi 1:0:0:0: Direct-Access ATA ST3320620AS 3.AA PQ: 0 ANSI: 5
SCSI device sdb: 625142448 512-byte hdwr sectors (320073 MB)
sdb: Write Protect is off
sdb: Mode Sense: 00 3a 00 00
SCSI device sdb: write cache: enabled, read cache: enabled, doesn't support DPO or FUA
SCSI device sdb: 625142448 512-byte hdwr sectors (320073 MB)
sdb: Write Protect is off
sdb: Mode Sense: 00 3a 00 00
SCSI device sdb: write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sdb: sdb1 sdb2 sdb3 sdb4 < sdb5 >
sd 1:0:0:0: Attached scsi disk sdb
ata_piix 0000:00:1f.5: MAP [ P0 P2 P1 P3 ]


HOWEVER,
(As per this FAQ from the libata homepage: http://linux-ata.org/faq.html)
When I do "cat /sys/block/sdX/device/queue_depth" I get a 1 instead of a 31 as per below article.

QUESTIONs
a.) Is NCQ enabled? (I'm thinking no)
b.) since the FAQ above states my chipset is compatible AND the feature is definitely getting recognised by the OS as per the log, is it safe to enable it?
c.) and to enable it, its "$ echo 31 > /sys/block/sdX/device/queue_depth" like the FAQ states?

also, if I do "hdparm -I /dev/sda" I get a * next to the NCQ feature set (which means its set?)

Thanks

vince_br549
2008-02-04, 04:23 PM CST
I think you are correct, that NCQ is not enabled on your machine.
On mine entering dmesg | grep -i ncq gives
ata1.00: 390721968 sectors, multi 8: LBA48 NCQ (depth 31/32)

cat /sys/block/sdX/device/queue_depth
if you get a number greater than 1 it is enabled

enable via
echo 31 > /sys/block/sdX/device/queue_depth
disable via
echo 1 > /sys/block/sdX/device/queue_depth

apparently there is a kernel bug in dealing with ncq that is supposed to be
fixed in 2.6.24

johannlo
2008-02-04, 09:09 PM CST
Thanks

Will wait till my next backup cycle then update and we'll see :)

How does this affect LVM? or can you apply this transparently? Do you have to unmount partitions beforehand? thanks in advance

vince_br549
2008-02-04, 10:01 PM CST
What I found out is that there is a ncq black list for specific drives.
Supposedly the black list is to be cleared in kernel 2.6.24. You might find the reason
yours comes up disabled is because it is on the black list.
the black list is in
/lib/modules/2.6.23.14-107.fc8/kernel/drivers/ata/libata.ko

you could do a
strings libata.ko|grep -i <your model>

I didn't find mine in the list. Previously I would notice a log of errors
in dmesg and then the kernel would disable ncq.

For some reason, my latest re-boot hasn't had any of the ncq errors.

vince_br549
2008-02-04, 10:12 PM CST
in /var/log/messages. I would see messages like
Jan 23 18:36:38 lap2 kernel: ata1.00: spurious completions during NCQ issue=0x0
SAct=0x7f9ff FIS=005040a1:00000400
Jan 23 18:36:38 lap2 kernel: ata1.00: NCQ disabled due to excessive errors

The last one I see was Jan 25 which is when I installed
2.6.23.14-107.fc8

vince_br549
2008-02-04, 10:13 PM CST
Oh, I forgot, I have no idea how this affects LVM. I don't use it.

johannlo
2008-02-05, 04:42 AM CST
I'll wait til the update then, I'm not having any performance complaints (its a fairly new rig, Core2Duo) so it it ain't broke :)

gala_dragos
2008-02-05, 05:35 AM CST
you also need the ahci kernel module load on boot. I've recently switched on the AHCI support on for my Gigabyte GA-P35-DS3L motherboard and I had to load ahci and sg modules for it to work properly. I've done this by including them in the initrd image that runs at startup.

You might have another option in your bios that prevents you from running sata in native mode, doesn't hurts if you read the bios manual that came with you motherboard.