Bug 218346

Summary: ASM1166 detects too many sata ports
Product: IO/Storage Reporter: Conrad Kostecki (ck+kernelbugzilla)
Component: Serial ATAAssignee: Tejun Heo (tj)
Status: RESOLVED CODE_FIX    
Severity: normal CC: andrebrait
Priority: P3    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:
Attachments: force_port_map_asm1166.patch
force_port_map_asm1166.patch

Description Conrad Kostecki 2024-01-05 00:04:49 UTC
If a ASM1166 S-ATA controller is being used, ahci does detect maximum count of 32 ports, which is clearly wrong. The ASM1166 only provides nativly 6 ports.

[   12.936774] ahci 0000:09:00.0: AHCI 0001.0301 32 slots 32 ports 6 Gbps 0xffffff3f impl SATA mode

[   12.914930] ahci 0000:09:00.0: SSS flag set, parallel bus scan disabled
[   12.936774] ahci 0000:09:00.0: AHCI 0001.0301 32 slots 32 ports 6 Gbps 0xffffff3f impl SATA mode
[   12.945708] ahci 0000:09:00.0: flags: 64bit ncq sntf stag pm led only pio sxs deso sadm sds apst
[   12.974660] scsi host9: ahci
[   12.978047] scsi host10: ahci
[   12.981670] scsi host11: ahci
[   12.985153] scsi host12: ahci
[   12.988501] scsi host13: ahci
[   12.991886] scsi host14: ahci
[   12.995263] scsi host15: ahci
[   12.998682] scsi host16: ahci
[   13.002143] scsi host17: ahci
[   13.005590] scsi host18: ahci
[   13.008970] scsi host19: ahci
[   13.012333] scsi host20: ahci
[   13.015734] scsi host21: ahci
[   13.019109] scsi host22: ahci
[   13.022474] scsi host23: ahci
[   13.025847] scsi host24: ahci
[   13.029189] scsi host25: ahci
[   13.032552] scsi host26: ahci
[   13.035921] scsi host27: ahci
[   13.039273] scsi host28: ahci
[   13.042620] scsi host29: ahci
[   13.045931] scsi host30: ahci
[   13.049297] scsi host31: ahci
[   13.052650] scsi host32: ahci
[   13.056000] scsi host33: ahci
[   13.059347] scsi host34: ahci
[   13.062666] scsi host35: ahci
[   13.066006] scsi host36: ahci
[   13.069336] scsi host37: ahci
[   13.072669] scsi host38: ahci
[   13.076003] scsi host39: ahci
[   13.079326] scsi host40: ahci
[   13.082505] ata9: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380100 irq 43
[   13.090114] ata10: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380180 irq 43
[   13.097817] ata11: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380200 irq 43
[   13.105500] ata12: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380280 irq 43
[   13.113188] ata13: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380300 irq 43
[   13.120802] ata14: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380380 irq 43
[   13.128455] ata15: DUMMY
[   13.131158] ata16: DUMMY
[   13.133892] ata17: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380500 irq 43
[   13.141577] ata18: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380580 irq 43
[   13.149271] ata19: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380600 irq 43
[   13.156955] ata20: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380680 irq 43
[   13.164648] ata21: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380700 irq 43
[   13.172332] ata22: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380780 irq 43
[   13.180017] ata23: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380800 irq 43
[   13.187687] ata24: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380880 irq 43
[   13.195371] ata25: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380900 irq 43
[   13.203043] ata26: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380980 irq 43
[   13.210727] ata27: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380a00 irq 43
[   13.218398] ata28: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380a80 irq 43
[   13.226083] ata29: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380b00 irq 43
[   13.233752] ata30: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380b80 irq 43
[   13.241437] ata31: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380c00 irq 43
[   13.249106] ata32: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380c80 irq 43
[   13.256793] ata33: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380d00 irq 43
[   13.264457] ata34: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380d80 irq 43
[   13.272127] ata35: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380e00 irq 43
[   13.279814] ata36: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380e80 irq 43
[   13.287486] ata37: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380f00 irq 43
[   13.295170] ata38: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf380f80 irq 43
[   13.302836] ata39: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf381000 irq 43
[   13.310519] ata40: SATA max UDMA/133 abar m8192@0xdf380000 port 0xdf381080 irq 43
[   17.683094] ata10: SATA link down (SStatus 0 SControl 300)
[   18.013067] ata11: SATA link down (SStatus 0 SControl 300)
[   18.342994] ata12: SATA link down (SStatus 0 SControl 300)
[   18.673104] ata13: SATA link down (SStatus 0 SControl 300)
[   19.002948] ata14: SATA link down (SStatus 0 SControl 300)
[   19.332904] ata17: SATA link down (SStatus 0 SControl 300)
[   19.663076] ata18: SATA link down (SStatus 0 SControl 300)
[   19.993125] ata19: SATA link down (SStatus 0 SControl 300)
[   20.323073] ata20: SATA link down (SStatus 0 SControl 300)
[   20.653208] ata21: SATA link down (SStatus 0 SControl 300)
[   20.983000] ata22: SATA link down (SStatus 0 SControl 300)
[   21.312937] ata23: SATA link down (SStatus 0 SControl 300)
[   21.643258] ata24: SATA link down (SStatus 0 SControl 300)
[   21.973075] ata25: SATA link down (SStatus 0 SControl 300)
[   22.302995] ata26: SATA link down (SStatus 0 SControl 300)
[   22.633094] ata27: SATA link down (SStatus 0 SControl 300)
[   22.962852] ata28: SATA link down (SStatus 0 SControl 300)
[   23.293135] ata29: SATA link down (SStatus 0 SControl 300)
[   23.623168] ata30: SATA link down (SStatus 0 SControl 300)
[   23.953094] ata31: SATA link down (SStatus 0 SControl 300)
[   24.283202] ata32: SATA link down (SStatus 0 SControl 300)
[   24.613073] ata33: SATA link down (SStatus 0 SControl 300)
[   24.942992] ata34: SATA link down (SStatus 0 SControl 300)
[   25.273184] ata35: SATA link down (SStatus 0 SControl 300)
[   25.603205] ata36: SATA link down (SStatus 0 SControl 300)
[   25.933031] ata37: SATA link down (SStatus 0 SControl 300)
[   26.263182] ata38: SATA link down (SStatus 0 SControl 300)
[   26.593193] ata39: SATA link down (SStatus 0 SControl 300)
[   26.923198] ata40: SATA link down (SStatus 0 SControl 300)


09:00.0 SATA controller: ASMedia Technology Inc. ASM1166 Serial ATA Controller (rev 02) (prog-if 01 [AHCI 1.0])
        Subsystem: ZyDAS Technology Corp. ASM1166 Serial ATA Controller
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Interrupt: pin A routed to IRQ 43
        Region 0: Memory at df382000 (32-bit, non-prefetchable) [size=8K]
        Region 5: Memory at df380000 (32-bit, non-prefetchable) [size=8K]
        Expansion ROM at df300000 [disabled] [size=512K]
        Capabilities: [40] Power Management version 3
                Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
                Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
                Address: 00000000fee004b8  Data: 0000
        Capabilities: [80] Express (v2) Endpoint, MSI 00
                DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s unlimited, L1 unlimited
                        ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 25W
                DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq-
                        RlxdOrd- ExtTag+ PhantFunc- AuxPwr- NoSnoop+
                        MaxPayload 128 bytes, MaxReadReq 128 bytes
                DevSta: CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr+ TransPend-
                LnkCap: Port #0, Speed 8GT/s, Width x2, ASPM L0s L1, Exit Latency L0s <4us, L1 <64us
                        ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
                LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk+
                        ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
                LnkSta: Speed 8GT/s, Width x2
                        TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
                DevCap2: Completion Timeout: Not Supported, TimeoutDis- NROPrPrP- LTR-
                         10BitTagComp- 10BitTagReq- OBFF Not Supported, ExtFmt- EETLPPrefix-
                         EmergencyPowerReduction Not Supported, EmergencyPowerReductionInit-
                         FRS- TPHComp- ExtTPHComp-
                         AtomicOpsCap: 32bit- 64bit- 128bitCAS-
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- LTR- 10BitTagReq- OBFF Disabled,
                         AtomicOpsCtl: ReqEn-
                LnkCap2: Supported Link Speeds: 2.5-8GT/s, Crosslink- Retimer- 2Retimers- DRS-
                LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis+
                         Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
                         Compliance Preset/De-emphasis: -6dB de-emphasis, 0dB preshoot
                LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete+ EqualizationPhase1+
                         EqualizationPhase2+ EqualizationPhase3+ LinkEqualizationRequest-
                         Retimer- 2Retimers- CrosslinkRes: unsupported
        Capabilities: [100 v1] Advanced Error Reporting
                UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
                CESta:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr-
                CEMsk:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr+
                AERCap: First Error Pointer: 00, ECRCGenCap- ECRCGenEn- ECRCChkCap- ECRCChkEn-
                        MultHdrRecCap- MultHdrRecEn- TLPPfxPres- HdrLogCap-
                HeaderLog: 00000000 00000000 00000000 00000000
        Capabilities: [130 v1] Secondary PCI Express
                LnkCtl3: LnkEquIntrruptEn- PerformEqu-
                LaneErrStat: 0
        Kernel driver in use: ahci
Comment 1 Conrad Kostecki 2024-01-05 12:52:52 UTC
Created attachment 305680 [details]
force_port_map_asm1166.patch

This patch forces the port_map for ASM1166, so only six ports are being used and rest marked as dummy.
Comment 2 Conrad Kostecki 2024-01-05 12:55:59 UTC
Created attachment 305681 [details]
force_port_map_asm1166.patch

The ASM1166 controller has 6 native sata ports. Unfortunately the controller always reports 32 sata ports, which can cause the boot process to be slow.

This patch limits this and forces port_map to six ports,
so the rest of the ports are being marked as DUMMY.
Comment 3 Conrad Kostecki 2024-01-23 19:20:50 UTC
@andrebrait: Hopyfully the patch gets mainlined in future: https://marc.info/?t=170603457700002&r=1&w=2
Comment 4 Andre Brait 2024-01-23 19:37:47 UTC
(In reply to Conrad Kostecki from comment #3)
> @andrebrait: Hopyfully the patch gets mainlined in future:
> https://marc.info/?t=170603457700002&r=1&w=2

Thanks a lot for the patch. 

I had looked into it myself, but due to lack of free time and the machine where the card is installed being somewhat hard to develop on, I couldn't test a solution.