From owner-svn-src-all@FreeBSD.ORG Fri Dec 2 12:52:33 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 994CC106564A; Fri, 2 Dec 2011 12:52:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 881158FC17; Fri, 2 Dec 2011 12:52:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB2CqX29093245; Fri, 2 Dec 2011 12:52:33 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB2CqX61093240; Fri, 2 Dec 2011 12:52:33 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201112021252.pB2CqX61093240@svn.freebsd.org> From: Alexander Motin Date: Fri, 2 Dec 2011 12:52:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228200 - in head: share/man/man4 sys/dev/ahci sys/dev/ata/chipsets X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Dec 2011 12:52:33 -0000 Author: mav Date: Fri Dec 2 12:52:33 2011 New Revision: 228200 URL: http://svn.freebsd.org/changeset/base/228200 Log: Add hw.ahci.force tunable to control whether AHCI drivers should attach to known AHCI-capable chips (AMD/NVIDIA), configured for legacy emulation. Enabled by default to get additional performance and functionality of AHCI when it can't be enabled by BIOS. Can be disabled to honor BIOS settings if needed for some reason. MFC after: 1 month Modified: head/share/man/man4/ahci.4 head/sys/dev/ahci/ahci.c head/sys/dev/ata/chipsets/ata-ati.c head/sys/dev/ata/chipsets/ata-nvidia.c Modified: head/share/man/man4/ahci.4 ============================================================================== --- head/share/man/man4/ahci.4 Fri Dec 2 11:55:09 2011 (r228199) +++ head/share/man/man4/ahci.4 Fri Dec 2 12:52:33 2011 (r228200) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 17, 2011 +.Dd December 2, 2011 .Dt AHCI 4 .Os .Sh NAME @@ -96,6 +96,9 @@ A manual bus reset is needed on device h .It Va hint.ahcich. Ns Ar X Ns Va .sata_rev setting to nonzero value limits maximum SATA revision (speed). Values 1, 2 and 3 are respectively 1.5, 3 and 6Gbps. +.It Va hw.ahci.force +setting to nonzero value forces driver attach to some known AHCI-capable +chips even if they are configured for legacy IDE emulation. Default is 1. .El .Sh DESCRIPTION This driver provides the Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Fri Dec 2 11:55:09 2011 (r228199) +++ head/sys/dev/ahci/ahci.c Fri Dec 2 12:52:33 2011 (r228200) @@ -291,6 +291,9 @@ static struct { #define RECOVERY_REQUEST_SENSE 2 #define recovery_slot spriv_field1 +static int force_ahci = 1; +TUNABLE_INT("hw.ahci.force", &force_ahci); + static int ahci_probe(device_t dev) { @@ -308,7 +311,8 @@ ahci_probe(device_t dev) for (i = 0; ahci_ids[i].id != 0; i++) { if (ahci_ids[i].id == devid && ahci_ids[i].rev <= revid && - (valid || !(ahci_ids[i].quirks & AHCI_Q_NOFORCE))) { + (valid || (force_ahci == 1 && + !(ahci_ids[i].quirks & AHCI_Q_NOFORCE)))) { /* Do not attach JMicrons with single PCI function. */ if (pci_get_vendor(dev) == 0x197b && (pci_read_config(dev, 0xdf, 1) & 0x40) == 0) Modified: head/sys/dev/ata/chipsets/ata-ati.c ============================================================================== --- head/sys/dev/ata/chipsets/ata-ati.c Fri Dec 2 11:55:09 2011 (r228199) +++ head/sys/dev/ata/chipsets/ata-ati.c Fri Dec 2 12:52:33 2011 (r228200) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); /* local prototypes */ static int ata_ati_chipinit(device_t dev); +static int ata_ati_dumb_ch_attach(device_t dev); static int ata_ati_ixp700_ch_attach(device_t dev); static int ata_ati_setmode(device_t dev, int target, int mode); @@ -63,6 +64,8 @@ static int ata_ati_setmode(device_t dev, #define SII_MEMIO 1 #define SII_BUG 0x04 +static int force_ahci = 1; +TUNABLE_INT("hw.ahci.force", &force_ahci); /* * ATI chipset support functions @@ -111,7 +114,10 @@ ata_ati_probe(device_t dev) ctlr->chipinit = ata_sii_chipinit; break; case ATI_AHCI: - ctlr->chipinit = ata_ahci_chipinit; + if (force_ahci == 1 || pci_get_subclass(dev) != PCIS_STORAGE_IDE) + ctlr->chipinit = ata_ahci_chipinit; + else + ctlr->chipinit = ata_ati_chipinit; break; } return (BUS_PROBE_DEFAULT); @@ -127,6 +133,11 @@ ata_ati_chipinit(device_t dev) if (ata_setup_interrupt(dev, ata_generic_intr)) return ENXIO; + if (ctlr->chip->cfg1 == ATI_AHCI) { + ctlr->ch_attach = ata_ati_dumb_ch_attach; + ctlr->setmode = ata_sata_setmode; + return (0); + } switch (ctlr->chip->chipid) { case ATA_ATI_IXP600: /* IXP600 only has 1 PATA channel */ @@ -165,6 +176,17 @@ ata_ati_chipinit(device_t dev) } static int +ata_ati_dumb_ch_attach(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (ata_pci_ch_attach(dev)) + return ENXIO; + ch->flags |= ATA_SATA; + return (0); +} + +static int ata_ati_ixp700_ch_attach(device_t dev) { struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); Modified: head/sys/dev/ata/chipsets/ata-nvidia.c ============================================================================== --- head/sys/dev/ata/chipsets/ata-nvidia.c Fri Dec 2 11:55:09 2011 (r228199) +++ head/sys/dev/ata/chipsets/ata-nvidia.c Fri Dec 2 12:52:33 2011 (r228200) @@ -65,6 +65,8 @@ static int ata_nvidia_setmode(device_t d #define NVAHCI 0x04 #define NVNOFORCE 0x08 +static int force_ahci = 1; +TUNABLE_INT("hw.ahci.force", &force_ahci); /* * nVidia chipset support functions @@ -181,7 +183,7 @@ ata_nvidia_probe(device_t dev) ata_set_desc(dev); if ((ctlr->chip->cfg1 & NVAHCI) && - ((ctlr->chip->cfg1 & NVNOFORCE) == 0 || + ((force_ahci == 1 && (ctlr->chip->cfg1 & NVNOFORCE) == 0) || pci_get_subclass(dev) != PCIS_STORAGE_IDE)) ctlr->chipinit = ata_ahci_chipinit; else