# viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes. # # Use via_chip_map() to attach this controller in IDE and RAID modes, # similarly to VX800, which allows drives to be identified and attached # successfully on all four ports (two channels with master/slave ports). # # Use sata_setup_channel to set up its channels instead of via_setup_channel. # This avoids writes to the 0x50 offset register, which is meaningful only # for IDE controllers (timing control). Writing to it in the SATA controller's # registers causes drives on the IDE controller (0x0571) not to attach at all. # (Apply this also to the other two SATA-only controllers: VX900 and VT8261). # # Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R AFAIK). # This PCI ID is used in RAID mode on newer (CE) chipset revision and in all modes # (IDE/RAID/AHCI) on the older one. # Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode). # Add both these IDs to the ahcisata(4) PCI quirk list. # Add 0x5287 PCI ID used in IDE mode on newer (CE) chipset revision. # # For more details on these decisions, please refer to the tech-kern mailing # list thread: # https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html # # Should fix and close PR kern/37517. # # Tested on Asus A8V-VM (CD revision) and MSI MS-7318 (CE revision) motherboards. diff --git a/sys/dev/pci/ahcisata_pci.c b/sys/dev/pci/ahcisata_pci.c index a87086fcdd9..751df9618d8 100644 --- a/sys/dev/pci/ahcisata_pci.c +++ b/sys/dev/pci/ahcisata_pci.c @@ -186,10 +186,10 @@ static const struct ahci_pci_quirk ahci_pci_quirks[] = { AHCI_QUIRK_BADPMP | AHCI_QUIRK_BADNCQ }, { PCI_VENDOR_ATI, PCI_PRODUCT_ATI_SB700_SATA_STORAGE, AHCI_QUIRK_BADPMP | AHCI_QUIRK_BADNCQ }, - { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8237R_SATA, - AHCI_QUIRK_BADPMP }, { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251_SATA, AHCI_QUIRK_BADPMP }, + { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251_AHCI, + AHCI_QUIRK_BADPMP }, { PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1061_01, AHCI_PCI_QUIRK_FORCE }, { PCI_VENDOR_ASMEDIA, PCI_PRODUCT_ASMEDIA_ASM1061_02, diff --git a/sys/dev/pci/pcidevs b/sys/dev/pci/pcidevs index d75c1fdc04e..8a552c8d3f1 100644 --- a/sys/dev/pci/pcidevs +++ b/sys/dev/pci/pcidevs @@ -10127,7 +10127,7 @@ product VIATECH VT8251 0x3287 VT8251 PCI-LPC Bridge product VIATECH VT8237A_HDA 0x3288 VT8237A/VT8251 High Definition Audio Controller product VIATECH VT8237A_ISA 0x3337 VT8237A/VT82C586A PCI-ISA Bridge product VIATECH VT3314_IG 0x3344 VT3314 CN900 UniChrome Integrated Graphics -product VIATECH VT8237R_SATA 0x3349 VT8237R Integrated SATA Controller +product VIATECH VT8251_SATA 0x3349 VT8251 Integrated SATA Controller product VIATECH VT3351_HB_3351 0x3351 VT3351 Host Bridge product VIATECH VX800_PPB_2 0x3353 VX800/VX820 PCI-PCI Bridge product VIATECH P4M900_3 0x3364 CN896/P4M900 Host Bridge @@ -10145,6 +10145,7 @@ product VIATECH VT3351_HB_4351 0x4351 VT3351 Host Bridge product VIATECH VX800_PMC 0x4353 VX800/VX820 Power Management Control product VIATECH P4M900_4 0x4364 CN896/P4M900 Host Bridge product VIATECH VX900_1 0x4410 VX900 Power Management Controller +product VIATECH VT8251_SATA_2 0x5287 VT8251 Integrated SATA Controller (IDE mode) product VIATECH CX700M2_IDE 0x5324 CX700(M2)/VX700/VX800/VX820 IDE Controller product VIATECH VT8237A_SATA_2 0x5337 VT8237A Integrated SATA Controller product VIATECH VT3351_IOAPIC 0x5351 VT3351 I/O APIC Interrupt Controller @@ -10153,7 +10154,7 @@ product VIATECH P4M900_IOAPIC 0x5364 CN896/P4M900 IOAPIC product VIATECH VT8237S_SATA 0x5372 VT8237S Integrated SATA Controller product VIATECH VX900_APIC 0x5410 VX900 APIC and Traffic Controller product VIATECH VT86C100A 0x6100 VT86C100A (Rhine-II) 10/100 Ethernet -product VIATECH VT8251_SATA 0x6287 VT8251 Integrated SATA Controller +product VIATECH VT8251_AHCI 0x6287 VT8251 Integrated AHCI SATA Controller product VIATECH VX800_SCRATCH 0x6353 VX800/VX820 Scratch Registers product VIATECH P4M900_6 0x6364 CN896/P4M900 Security Device product VIATECH VX900_SCRATCH 0x6410 VX900 Scratch Registers diff --git a/sys/dev/pci/viaide.c b/sys/dev/pci/viaide.c index 5631726f0fd..42b942ead1a 100644 --- a/sys/dev/pci/viaide.c +++ b/sys/dev/pci/viaide.c @@ -349,10 +349,24 @@ static const struct pciide_product_desc pciide_via_products[] = { "VIA Technologies VT8237A (5337) SATA Controller", via_sata_chip_map_7, }, - { PCI_PRODUCT_VIATECH_VT8237R_SATA, + /* + * The 0x3349 PCI ID may be reused in all modes (IDE, RAID, AHCI). + * ahcisata(4) will attach if AHCI mode is selected in the BIOS. + * Newer CE revision southbridges use it only in RAID mode. + */ + { PCI_PRODUCT_VIATECH_VT8251_SATA, 0, - "VIA Technologies VT8237R SATA Controller", - via_sata_chip_map_7, + "VIA Technologies VT8251 SATA Controller", + via_chip_map, + }, + /* + * The 0x5287 PCI ID is used only in IDE mode for newer + * VT8251 southbridge (CE) revisions. + */ + { PCI_PRODUCT_VIATECH_VT8251_SATA_2, + 0, + "VIA Technologies VT8251 (5287) SATA Controller", + via_chip_map, }, { PCI_PRODUCT_VIATECH_VT8237S_SATA, 0, @@ -501,12 +515,18 @@ via_chip_map(struct pciide_softc *sc, const struct pci_attach_args *pa) no_ideconf = 1; /* FALLTHROUGH */ case PCI_PRODUCT_VIATECH_CX700_IDE: + sc->sc_wdcdev.sc_atac.atac_udma_cap = 6; + break; + case PCI_PRODUCT_VIATECH_VT8251_SATA: + /* FALLTHROUGH */ + case PCI_PRODUCT_VIATECH_VT8251_SATA_2: /* FALLTHROUGH */ case PCI_PRODUCT_VIATECH_VT8261_SATA: /* FALLTHROUGH */ case PCI_PRODUCT_VIATECH_VX900_IDE: /* FALLTHROUGH */ case PCI_PRODUCT_VIATECH_VX900_RAID: + sc->sc_wdcdev.sc_atac.atac_set_modes = sata_setup_channel; sc->sc_wdcdev.sc_atac.atac_udma_cap = 6; break; default: @@ -662,7 +682,8 @@ via_chip_map(struct pciide_softc *sc, const struct pci_attach_args *pa) } sc->sc_wdcdev.sc_atac.atac_pio_cap = 4; sc->sc_wdcdev.sc_atac.atac_dma_cap = 2; - sc->sc_wdcdev.sc_atac.atac_set_modes = via_setup_channel; + if (sc->sc_wdcdev.sc_atac.atac_set_modes == NULL) + sc->sc_wdcdev.sc_atac.atac_set_modes = via_setup_channel; sc->sc_wdcdev.sc_atac.atac_channels = sc->wdc_chanarray; if (single_channel) sc->sc_wdcdev.sc_atac.atac_nchannels = 1;