Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[WORKAROUND] Slow drive detection on unused SATA ports
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Maf
Apprentice
Apprentice


Joined: 15 May 2005
Posts: 299

PostPosted: Sun May 10, 2020 7:44 pm    Post subject: [WORKAROUND] Slow drive detection on unused SATA ports Reply with quote

My setup: 4 drives (3x SSD, 1x DVD), 8 SATA ports

Is this normal that Linux needs ~1 second to find out that a SATA port is unused? Unfortunately I can't disable them in my mainboard's BIOS (Asus X470-F).

Or am I misinterpreting the log messages and there are some problem here?

Code:

[...]
[    0.962831] ata9: SATA link down (SStatus 0 SControl 300)
[    0.968831] ata10: SATA link down (SStatus 0 SControl 300)
[    1.068196] usb 1-9: new full-speed USB device number 2 using xhci_hcd
[    1.121204] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[    1.122921] ata1.00: supports DRM functions and may not be fully accessible
[    1.123637] ata1.00: disabling queued TRIM support
[    1.123638] ata1.00: ATA-9: Samsung SSD 850 EVO 500GB, EMT02B6Q, max UDMA/133
[    1.123767] ata1.00: 976773168 sectors, multi 1: LBA48 NCQ (depth 32), AA
[    1.125584] ata1.00: supports DRM functions and may not be fully accessible
[    1.126245] ata1.00: disabling queued TRIM support
[    1.127677] ata1.00: configured for UDMA/133
[    1.127849] scsi 0:0:0:0: Direct-Access     ATA      Samsung SSD 850  2B6Q PQ: 0 ANSI: 5
[    1.128103] sd 0:0:0:0: Attached scsi generic sg0 type 0
[    1.128126] sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/466 GiB)
[    1.128431] sd 0:0:0:0: [sda] Write Protect is off
[    1.128553] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
[    1.128557] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.129007]  sda: sda1 sda2 sda3
[    1.129329] sd 0:0:0:0: [sda] Attached SCSI disk
[    1.139196] usb 5-4: new low-speed USB device number 2 using xhci_hcd
[    1.284217] usb 5-4: New USB device found, idVendor=046d, idProduct=c077, bcdDevice=72.00
[    1.284405] usb 5-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    1.284534] usb 5-4: Product: USB Optical Mouse
[    1.284654] usb 5-4: Manufacturer: Logitech
[    1.302317] input: Logitech USB Optical Mouse as /devices/pci0000:00/0000:00:08.1/0000:0a:00.3/usb5/5-4/5-4:1.0/0003:046D:C077.0001/input/input12
[    1.302581] hid-generic 0003:046D:C077.0001: input,hidraw0: USB HID v1.11 Mouse [Logitech USB Optical Mouse] on usb-0000:0a:00.3-4/input0
[    1.380227] usb 1-9: New USB device found, idVendor=0b05, idProduct=1872, bcdDevice= 2.00
[    1.380415] usb 1-9: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    1.380543] usb 1-9: Product: AURA LED Controller
[    1.380664] usb 1-9: Manufacturer: AsusTek Computer Inc.
[    1.380786] usb 1-9: SerialNumber: 00000000001A
[    1.399372] hid-generic 0003:0B05:1872.0002: hiddev96,hidraw1: USB HID v1.11 Device [AsusTek Computer Inc. AURA LED Controller] on usb-0000:01:00.0-9/input0
[    1.601621] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[    1.602795] ata2.00: supports DRM functions and may not be fully accessible
[    1.603470] ata2.00: ATA-11: Samsung SSD 860 EVO 1TB, RVT03B6Q, max UDMA/133
[    1.603598] ata2.00: 1953525168 sectors, multi 1: LBA48 NCQ (depth 32), AA
[    1.605746] ata2.00: supports DRM functions and may not be fully accessible
[    1.607875] ata2.00: configured for UDMA/133
[    1.608083] scsi 1:0:0:0: Direct-Access     ATA      Samsung SSD 860  3B6Q PQ: 0 ANSI: 5
[    1.608374] ata2.00: Enabling discard_zeroes_data
[    1.608379] sd 1:0:0:0: Attached scsi generic sg1 type 0
[    1.608513] sd 1:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[    1.608810] sd 1:0:0:0: [sdb] Write Protect is off
[    1.608931] sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
[    1.608936] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.609463] ata2.00: Enabling discard_zeroes_data
[    1.610524]  sdb: sdb1
[    1.610821] ata2.00: Enabling discard_zeroes_data
[    1.610964] sd 1:0:0:0: [sdb] Attached SCSI disk
[    1.689623] tsc: Refined TSC clocksource calibration: 3493.436 MHz
[    1.689757] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x325b186289d, max_idle_ns: 440795326624 ns
[    1.690049] clocksource: Switched to clocksource tsc
[    1.922180] ata3: SATA link down (SStatus 0 SControl 330)
[    2.234301] ata4: SATA link down (SStatus 0 SControl 330)
[    2.705628] ata5: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[    2.707700] ata5.00: supports DRM functions and may not be fully accessible
[    2.708820] ata5.00: NCQ Send/Recv Log not supported
[    2.708944] ata5.00: ATA-9: Samsung SSD 850 EVO 250GB, EMT01B6Q, max UDMA/133
[    2.710323] ata5.00: 488397168 sectors, multi 1: LBA48 NCQ (depth 32), AA
[    2.711675] ata5.00: supports DRM functions and may not be fully accessible
[    2.712138] ata5.00: NCQ Send/Recv Log not supported
[    2.713049] ata5.00: configured for UDMA/133
[    2.713272] scsi 4:0:0:0: Direct-Access     ATA      Samsung SSD 850  1B6Q PQ: 0 ANSI: 5
[    2.713572] sd 4:0:0:0: [sdc] 488397168 512-byte logical blocks: (250 GB/233 GiB)
[    2.713572] sd 4:0:0:0: Attached scsi generic sg2 type 0
[    2.713892] sd 4:0:0:0: [sdc] Write Protect is off
[    2.714013] sd 4:0:0:0: [sdc] Mode Sense: 00 3a 00 00
[    2.714017] sd 4:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    2.714726]  sdc: sdc1 sdc2
[    2.715156] sd 4:0:0:0: [sdc] Attached SCSI disk
[    3.185624] ata6: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[    3.188876] ata6.00: ATAPI: HL-DT-ST DVDRAM GSA-H62N, CL00, max UDMA/100
[    3.193299] ata6.00: configured for UDMA/100
[    3.306373] scsi 5:0:0:0: CD-ROM            HL-DT-ST DVDRAM GSA-H62N  CL00 PQ: 0 ANSI: 5
[    3.453076] sr 5:0:0:0: [sr0] scsi3-mmc drive: 48x/48x writer dvd-ram cd/rw xa/form2 cdda tray
[    3.453271] cdrom: Uniform CD-ROM driver Revision: 3.20
[    3.453717] sr 5:0:0:0: Attached scsi CD-ROM sr0
[    3.453762] sr 5:0:0:0: Attached scsi generic sg3 type 5
[    4.489613] ata7: failed to resume link (SControl 0)
[    4.489750] ata7: SATA link down (SStatus 0 SControl 0)
[    5.529616] ata8: failed to resume link (SControl 0)
[    5.529754] ata8: SATA link down (SStatus 0 SControl 0)
[    5.529964] md: Waiting for all devices to be available before autodetect
[    5.530092] md: If you don't use raid, use raid=noautodetect
[    5.530339] md: Autodetecting RAID arrays.
[    5.530457] md: autorun ...
[    5.530570] md: ... autorun DONE.
[    5.533658] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null)
[    5.533857] VFS: Mounted root (ext4 filesystem) readonly on device 8:2.
[    5.534718] devtmpfs: mounted
[    5.535073] Freeing unused kernel image (initmem) memory: 1172K
[...]


Last edited by Maf on Sat May 16, 2020 6:59 pm; edited 1 time in total
Back to top
View user's profile Send private message
Maf
Apprentice
Apprentice


Joined: 15 May 2005
Posts: 299

PostPosted: Sat May 16, 2020 6:58 pm    Post subject: Reply with quote

Well I did some research and found a reason + a workaround.

It turns out the slow part was kernel trying to talk to non-existing SATA ports.

This is how kernel's ata devices are mapped to physical ports on my system:
Code:

ata1 -> SATA6G_1
ata2 -> SATA6G_2
ata3 -> SATA6G_5
ata4 -> SATA6G_6
ata5 -> SATA6G_3
ata6 -> SATA6G_4
ata7 -> (no port)
ata8 -> (no port)
ata9 -> M.2_1
ata10 -> M.2_2


Both M.2 ports are handled by another controller, so let's put them aside.

You may ask: why are ata7 and ata8 listed there when they don't exist? Well, during AHCI host initialization ASM1062 used in AMD's X470 is queried to get number of supported (Capabilities/Number of ports - NP) and actually implemented/mapped (Ports implemented - PI) SATA ports (more details: https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/serial-ata-ahci-spec-rev1-3-1.pdf).

The number returned to the kernel are:
NP = 8, PI = 8 (0x00ff)
The correct numbers would be:
NP = 8, PI = 6 (0x003f)

AFAIK BIOS initializes these values, so ASUS would be the one the set them correctly.

So I patched the kernel and fix it myself:
Code:

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 8c6f8c83dd6f..c8048032cca9 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -634,6 +634,12 @@ static void ahci_pci_save_initial_config(struct pci_dev *pdev,
                hpriv->force_port_map = 1;
        }
 
+       if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x43c8 &&
+               pdev->subsystem_vendor == PCI_VENDOR_ID_ASMEDIA && pdev->subsystem_device == 0x1062) {
+                       dev_info(&pdev->dev, "ASM1062 @ Asus X470-F has only 6 ports; forcing port map to 0x3f");
+                       hpriv->force_port_map = 0x3f;
+       }
+
        /*
         * Temporary Marvell 6145 hack: PATA port presence
         * is asserted through the standard AHCI port


Results:
Code:

[    0.651418] ata1: SATA max UDMA/133 abar m131072@0xf6780000 port 0xf6780100 irq 41
[    0.651607] ata2: SATA max UDMA/133 abar m131072@0xf6780000 port 0xf6780180 irq 41
[    0.651799] ata3: SATA max UDMA/133 abar m131072@0xf6780000 port 0xf6780200 irq 41
[    0.651989] ata4: SATA max UDMA/133 abar m131072@0xf6780000 port 0xf6780280 irq 41
[    0.652175] ata5: SATA max UDMA/133 abar m131072@0xf6780000 port 0xf6780300 irq 41
[    0.652361] ata6: SATA max UDMA/133 abar m131072@0xf6780000 port 0xf6780380 irq 41
[    0.652549] ata7: DUMMY
[    0.652669] ata8: DUMMY
[    0.653498] ata9: SATA max UDMA/133 abar m2048@0xf6900000 port 0xf6900100 irq 43
[    0.654360] ata10: SATA max UDMA/133 abar m2048@0xf6800000 port 0xf6800100 irq 45
[    0.962946] ata9: SATA link down (SStatus 0 SControl 300)
[    0.969948] ata10: SATA link down (SStatus 0 SControl 300)
[    1.120208] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[    1.600636] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[    1.920989] ata3: SATA link down (SStatus 0 SControl 330)
[    2.233109] ata4: SATA link down (SStatus 0 SControl 330)
[    2.704632] ata5: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[    3.184633] ata6: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[    3.469617] Run /sbin/init as init process


2 seconds saved from each boot ;)
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7446
Location: almost Mile High in the USA

PostPosted: Sat May 16, 2020 7:24 pm    Post subject: Reply with quote

Interesting, was hoping to find a solution to a similar problem I have on my eeePC and SSD.

The SSD is weird, for some reason it shows up as slave instead of the original SSD which shows up as master.

When the kernel polls for master, it takes several seconds before giving up, and then goes onto the slave port...which works perfectly fine.
Now I need to figure out how to make it stop scanning master... or figure out how to make the mPCIe SATA card show up as master instead of slave.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum