lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-id: <45276085.3040102@shaw.ca>
Date:	Sat, 07 Oct 2006 02:08:37 -0600
From:	Robert Hancock <hancockr@...w.ca>
To:	linux-kernel <linux-kernel@...r.kernel.org>,
	linux-ide@...r.kernel.org
Cc:	prakash@...noor.de, jeff@...zik.org
Subject: [RFC PATCH] nForce4 ADMA with NCQ: It's aliiiive..

I've been working on the patch for sata_nv ADMA support for nForce4 that 
Jeff Garzik has in a git branch. I've gotten it into a state where the 
ADMA and NCQ features appear to be working with no obvious problems. 
I've attached a patch against 2.6.18-mm2.

The code was mostly in a working state for the non-NCQ case but there 
were a number of heinous bugs that prevented NCQ from working, like in 
the sg list to APRD conversion code and in the interrupt handler.

This is still in quite an experimental state. It has survived system 
boots into Fedora Core 5 and Bonnie++ benchmark runs without blowing up, 
but there could still be bugs that could corrupt data, etc. so test with 
caution.

There is a module parameter adma_enabled which has to be set to 1 to 
enable ADMA on CK804/MCP04 chipsets (either that or hack the code to 
make the default 1). I only enabled ADMA on those chipsets and not 
MCP51, MCP55 or MCP61 since that was all that the original NVIDIA 
version did. I assume there was a reason for this, though maybe not. 
Someone with one of these chipsets should probably try it out (replacing 
the GENERIC type with CK804 in the PCI device table may be all it takes).

A few outstanding issues:

-Error handling likely needs work. EH works well enough to get past 
drive detection but that's likely about all. When I ran into errors 
while debugging, it usually locked up the machine when trying to do a 
soft reset.

-Error handling is also noisy at the moment (it dumps a bunch of 
controller state information).

-Jeff will probably cringe at how I implemented the 
bmdma_stop/start/status/setup functions. This kludge of toggling 
ATA_FLAG_MMIO off for the call into libata was needed since this 
controller is almost what libata calls ATA_FLAG_MMIO, but not quite (the 
ATA taskfile registers are MMIO but the BMDMA registers are PIO). This 
is also why I needed the patch to libata-sff.c to use the adapter's 
bmdma_status function rather than hardcoded ata_bmdma_status.

Some sample dmesg output:

sata_nv 0000:00:07.0: version 2.1
sata_nv 0000:00:07.0: Using ADMA mode
ACPI: PCI Interrupt Link [APSI] enabled at IRQ 23
ACPI: PCI Interrupt 0000:00:07.0[A] -> Link [APSI] -> GSI 23 (level, 
low) -> IRQ 23
PCI: Setting latency timer of device 0000:00:07.0 to 64
sata_nv 0000:00:07.0: Resetting port 0
ata1: SATA max UDMA/133 cmd 0xFFFFC20000004480 ctl 0xFFFFC200000044A0 
bmdma 0xD800 irq 23
sata_nv 0000:00:07.0: Resetting port 1
ata2: SATA max UDMA/133 cmd 0xFFFFC20000004580 ctl 0xFFFFC200000045A0 
bmdma 0xD808 irq 23
scsi0 : sata_nv
PM: Adding info for No Bus:host0
sata_nv 0000:00:07.0: Error handling port 0, notifier 0x0, 
notifier_error 0x0, gen_ctl 0x1501000, int pending 0, status 0x700, 
dumping CPB states
ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
ata1.00: ATA-6, max UDMA/133, 312581808 sectors: LBA48 NCQ (depth 31/32)
ata1.00: ata1: dev 0 multi count 1
ata1.00: configured for UDMA/133
scsi1 : sata_nv
PM: Adding info for No Bus:host1
sata_nv 0000:00:07.0: Error handling port 1, notifier 0x0, 
notifier_error 0x0, gen_ctl 0x1501000, int pending 0, status 0x700, 
dumping CPB states
ata2: SATA link down (SStatus 0 SControl 300)
PM: Adding info for No Bus:target0:0:0
scsi 0:0:0:0: Direct-Access     ATA      ST3160827AS      3.42 PQ: 0 ANSI: 5
PM: Adding info for scsi:0:0:0:0
SCSI device sda: 312581808 512-byte hdwr sectors (160042 MB)
sda: Write Protect is off
sda: Mode Sense: 00 3a 00 00
SCSI device sda: drive cache: write back
SCSI device sda: 312581808 512-byte hdwr sectors (160042 MB)
sda: Write Protect is off
sda: Mode Sense: 00 3a 00 00
SCSI device sda: drive cache: write back
  sda: sda1
sd 0:0:0:0: Attached scsi disk sda
sata_nv 0000:00:08.0: Using ADMA mode
ACPI: PCI Interrupt Link [APSJ] enabled at IRQ 22
ACPI: PCI Interrupt 0000:00:08.0[A] -> Link [APSJ] -> GSI 22 (level, 
low) -> IRQ 22
PCI: Setting latency timer of device 0000:00:08.0 to 64
sata_nv 0000:00:08.0: Resetting port 0
ata3: SATA max UDMA/133 cmd 0xFFFFC20000006480 ctl 0xFFFFC200000064A0 
bmdma 0xC400 irq 22
sata_nv 0000:00:08.0: Resetting port 1
ata4: SATA max UDMA/133 cmd 0xFFFFC20000006580 ctl 0xFFFFC200000065A0 
bmdma 0xC408 irq 22
scsi2 : sata_nv
PM: Adding info for No Bus:host2
sata_nv 0000:00:08.0: Error handling port 0, notifier 0x0, 
notifier_error 0x0, gen_ctl 0x1501000, int pending 0, status 0x700, 
dumping CPB states
ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata3.00: ATA-7, max UDMA/133, 625142448 sectors: LBA48 NCQ (depth 31/32)
ata3.00: ata3: dev 0 multi count 1
ata3.00: configured for UDMA/133
scsi3 : sata_nv
PM: Adding info for No Bus:host3
sata_nv 0000:00:08.0: Error handling port 1, notifier 0x0, 
notifier_error 0x0, gen_ctl 0x1501000, int pending 0, status 0x700, 
dumping CPB states
ata4: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
ata4.00: ATA-6, max UDMA/133, 312581808 sectors: LBA48 NCQ (depth 31/32)
ata4.00: ata4: dev 0 multi count 1
ata4.00: configured for UDMA/133
PM: Adding info for No Bus:target2:0:0
scsi 2:0:0:0: Direct-Access     ATA      ST3320620AS      3.AA PQ: 0 ANSI: 5
PM: Adding info for scsi:2:0:0:0
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: drive cache: write back
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: drive cache: write back
  sdb: sdb1
sd 2:0:0:0: Attached scsi disk sdb
PM: Adding info for No Bus:target3:0:0
scsi 3:0:0:0: Direct-Access     ATA      ST3160827AS      3.42 PQ: 0 ANSI: 5
PM: Adding info for scsi:3:0:0:0
SCSI device sdc: 312581808 512-byte hdwr sectors (160042 MB)
sdc: Write Protect is off
sdc: Mode Sense: 00 3a 00 00
SCSI device sdc: drive cache: write back
SCSI device sdc: 312581808 512-byte hdwr sectors (160042 MB)
sdc: Write Protect is off
sdc: Mode Sense: 00 3a 00 00
SCSI device sdc: drive cache: write back
  sdc: sdc1 sdc2 sdc3 sdc4 < sdc5 >
sd 3:0:0:0: Attached scsi disk sdc

Finally some Bonnie++ results from before, without NCQ:

Version  1.03       ------Sequential Output------ --Sequential Input- 
--Random-
                     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- 
--Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP 
/sec %CP
newcastle.ss.sha 4G 33185  79 36840  33 16170   9 33461  73 39788   7 
179.4   1
                     ------Sequential Create------ --------Random 
Create--------
                     -Create-- --Read--- -Delete-- -Create-- --Read--- 
-Delete--
               files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP 
/sec %CP
                  16  6920  81 +++++ +++ 15820 100  8286  99 +++++ +++ 
15874  98

and with NCQ:

Version  1.03       ------Sequential Output------ --Sequential Input- 
--Random-
                     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- 
--Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP 
/sec %CP
newcastle.ss.sha 4G 27068  66 31907  26 17020   8 29163  77 40032   8 
205.0   0
                     ------Sequential Create------ --------Random 
Create--------
                     -Create-- --Read--- -Delete-- -Create-- --Read--- 
-Delete--
               files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP 
/sec %CP
                  16  9566  91 +++++ +++ 16387  99 10606  99 +++++ +++ 
23773  99

It looks like there was a bit of a drop in sequential output and 
sequential character input, but everything else went up..

In case anyone wants to actually apply this to something:

Signed-off-by: Robert Hancock <hancockr@...w.ca>

-- 
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@...pamshaw.ca
Home Page: http://www.roberthancock.com/


View attachment "sata_nv-adma-ncq.patch" of type "text/plain" (30760 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ