转载请注明原文出处!
【声明】
使用本文提供的方法设置ACHI而对硬件造成的损失,本人不承担任何责任!!
(理论上是没什么问题的,还是声明下的好 :-|)
====================================================================================================================================
【问题】
我的本子是Dell XPS M1210(南桥是ICH7-M),BIOS经升级到了最新的A08。
但是BIOS还是没有修改磁盘运行模式的选项(IDE与AHCI的切换选项),所以我的硬盘一直跑在IDE Mode。执行 lspci -nn 会看到:
00:1f.2 SATA controller [0106]: Intel Corporation 82801GBM/GHM (ICH7-M Family) SATA Controller [IDE mode] [8086:27c4] (rev 01)
【方案】
事实ICH7-M的磁盘控制器是支持AHCI模式的,也就是说需要自己动手解决这个问题。
方案就是根据ICH7的Datasheet第12.1.33章节关于磁盘控制器的描述在Linux内核中添加代码对其寄存器进行设置。
然后重新编译内核,并使用新内核启动系统就OK了。
【代码】
1、本代码是我很久前从国外一个网站搞到的,但是在我这里无法成功设置。昨天又想起这个事了就翻了翻ICH7的Datasheet并修改了这段代码。
2、我在3.9-rc3内核测试成功的,其实只要追加这段代码后内核能编译过就能正常使用。
3、不需要添加内核启动参数 quirk_ich_force_ahci。(作者的原代码为了安全需要添加这个内核启动参数才会生效)
4、将本代码追加到driver/pci/quirks.c文件底部即可。
/*
* ICH7 force AHCI mode
* 2013-04-03, Niu Chenguang <chrsiniu1984@gmail.com>
*
* 将本代码追加到driver/pci/quirks.c文件底部即可
* ----------------------------------------------------------------------------
* 原作者注释
* ----------------------------------------------------------------------------
* Force ICH7/8/9 into AHCI mode. This is needed because some
* BIOSes do not make AHCI-mode operation available to the user.
* As the Intel documentation states that the OS should not carry
* out the operation - the user must force this on the kernel
* commandline using quirk_ich_force_ahci
*
* As this quirk gets called whilst the PCI subsystem is
* walking the PCI bus, we declare this quirk against the LPC
* (device 00:1f.0), so that we can frob 00:1f.2 before the PCI
* code has scanned it.
* Note: the pci id might change due to this (e.g. from 27c4 to 27c5)
* ----------------------------------------------------------------------------
*
*/
static void ich789_force_ahci_mode(struct pci_dev *pdev)
{
u8 amrval;
const int ich89_address_map_reg = 0x90;
/* ICH7 datasheet section 12.1.33 */
if (!pci_bus_read_config_byte(pdev->bus, PCI_DEVFN(PCI_SLOT(pdev->devfn), 2),
ich89_address_map_reg, &amrval)) {
if (amrval & (BIT(6) | BIT(7))) {
dev_printk(KERN_DEBUG, &pdev->dev,
"ICH7/8/9 SATA controller not in IDE mode. Not modifying.\n");
return;
}
/* Non-combined */
amrval &= ~BIT(0);
amrval &= ~BIT(1);
/* AHCI mode */
amrval |= BIT(6);
amrval &= ~BIT(7);
pci_bus_write_config_byte(pdev->bus, PCI_DEVFN(PCI_SLOT(pdev->devfn), 2),
ich89_address_map_reg, amrval);
dev_printk(KERN_DEBUG, &pdev->dev, "Forced ICH7/8/9 mode PIIX->AHCI\n");
}
}
/* ICH7-M */
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x27b9, ich789_force_ahci_mode);
成功后执行 lspci -nn 会看到控制器ID会从27c4变为27c5:
00:1f.2 SATA controller [0106]: Intel Corporation 82801GBM/GHM (ICH7-M Family) SATA Controller [AHCI mode] [8086:27c5] (rev 01)