Project

General

Profile

Bug #1648

JMicron JMB363: switch from RAID to AHCI mode

Added by George Null almost 8 years ago. Updated over 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
driver - device drivers
Start date:
2011-10-14
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

When using a JMicron JMB363 controller card, the device is recognized as a raid controller, even if there is no raid configured in the controller's bios. There is no option in the controller's bios to put it into ahci mode. (Apparently, mainboards which have a JMB363 onboard put it into ahci mode when the respective value is set in the mainboard's bios, so in that case seems to work ootb.)

lspci -v

04:00.0 RAID bus controller: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller (rev 10)
        Subsystem: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller
        Flags: bus master, fast devsel, latency 0, IRQ 10
        I/O ports at ec00
        I/O ports at e880
        I/O ports at e800
        I/O ports at e480
        I/O ports at e400
        Memory at f7fffc00 (32-bit, non-prefetchable)
        Expansion ROM at f7fe0000 [disabled]
        Capabilities: [8c] Power Management version 3
        Capabilities: [50] Express Legacy Endpoint, MSI 00

Since there is no driver for the raid mode of this controller, it needs to be switched to ahci mode to be able to use the device with the ahci driver. This can be achieved by modifying pci registers using setpci (from pciutils, http://mj.ucw.cz/pciutils.html):

setpci -v -s 04:00.0 40.b=b3 41.b=a1 42.b=c2

, where 04:00.0 is the bus address of the device.

Now the P-ATA and S-ATA ports of the controller are recognized as separate functions of the device:

04:00.0 SATA controller: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller (rev 10) (prog-if 01 [AHCI 1.0])
        Subsystem: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller
        Flags: bus master, fast devsel, latency 0, IRQ 10
        Memory at f7fffc00 (32-bit, non-prefetchable)
        Expansion ROM at f7fe0000 [disabled]
        Capabilities: [8c] Power Management version 3
        Capabilities: [50] Express Legacy Endpoint, MSI 00

04:00.1 IDE interface: JMicron Technologies, Inc. Unknown device 0368 (rev 10) (prog-if 85 [Master SecO PriO])
        Subsystem: JMicron Technologies, Inc. Unknown device 1368
        Flags: fast devsel
        I/O ports at ec00 [disabled]
        I/O ports at e880 [disabled]
        I/O ports at e800 [disabled]
        I/O ports at e480 [disabled]
        I/O ports at e400 [disabled]
        Capabilities: [8c] Power Management version 3
        Capabilities: [50] Express Legacy Endpoint, MSI 00

Assigning the ahci driver to the device:

update_drv -a -i '"pci197b,2363"' ahci

/var/adm/messages:

Oct 14 18:33:14 oi ahci: [ID 405770 kern.info] NOTICE: ahci2: hba AHCI version = 1.10
Oct 14 18:33:15 oi sata: [ID 663010 kern.info] /pci@0,0/pci8086,3a40@1c/pci197b,2363@0 :
Oct 14 18:33:15 oi sata: [ID 761595 kern.info]     SATA disk device at port 0
...
Oct 14 18:33:15 oi scsi: [ID 583861 kern.info] sd10 at ahci2: target 0 lun 0
Oct 14 18:33:15 oi genunix: [ID 936769 kern.info] sd10 is /pci@0,0/pci8086,3a40@1c/pci197b,2363@0/disk@0,0
Oct 14 18:33:15 oi genunix: [ID 408114 kern.info] /pci@0,0/pci8086,3a40@1c/pci197b,2363@0/disk@0,0 (sd10) online
Oct 14 18:33:15 oi sata: [ID 663010 kern.info] /pci@0,0/pci8086,3a40@1c/pci197b,2363@0 :
Oct 14 18:33:15 oi sata: [ID 761595 kern.info]     SATA disk device at port 1
...
Oct 14 18:33:15 oi scsi: [ID 583861 kern.info] sd11 at ahci2: target 1 lun 0
Oct 14 18:33:15 oi genunix: [ID 936769 kern.info] sd11 is /pci@0,0/pci8086,3a40@1c/pci197b,2363@0/disk@1,0
Oct 14 18:33:15 oi genunix: [ID 408114 kern.info] /pci@0,0/pci8086,3a40@1c/pci197b,2363@0/disk@1,0 (sd11) online

It would be nice to have the pci "quirk" integrated into the driver, like it is done in the linux kernel driver (http://lxr.free-electrons.com/source/drivers/pci/quirks.c, ll.1523ff.)


Files

pci_boot.diff (1.46 KB) pci_boot.diff Bill Sommerfeld, 2011-11-20 08:55 AM

History

#1

Updated by Bill Sommerfeld over 7 years ago

I purchased one of those cards recently and stumbled into this.

I have a somewhat crude hack which works for me (at least, it gets the IDE port working well enough to talk to a DVD drive, which is what I needed).
It works for me, but it's not pretty and I'm not proud of my work. Unfortunately, this is not something you can patch in the leaf driver; it has to go into the PCI autoconfiguration mechanism.

Note that:
1) if you added pci197b,2363 to /etc/driver_aliases via update_drv, be sure to remove it, as it will cause ahci to attempt to attach to both function 0 (which works) and function 1, which this patch sets up as a PCI IDE controller, not an AHCI controller (in this case, the correct drivers attach using the PCI class values rather than the vendor/device id's).

Before I deleted the driver alias, I got a whole bunch of:
Nov 19 23:27:36 hydra ahci: [ID 657069 kern.warning] WARNING: ahci2: Cannot map register space
Nov 19 23:27:36 hydra ahci: [ID 701872 kern.warning] WARNING: ahci2: Cannot find AHCI register set
and FMA marked function 1 as "retired" (aka "I think it's broken").

2) it is possible that this change may have undesirable side effects - if a motherboard using this chip sets up the SATA ports into PCI IDE mode rather than AHCI mode (assuming this chip is capable of being setup that way..), upgrading to a version of illumos with this change may cause device paths and /dev/dsk names to shift out from underneath the kernel.  I wouldn't be surprised to find out that this triggers a vfs_mountroot panic in that case.

there are two parts to this patch, which both apply to uts/intel/io/pci/pci_boot.c
1) change device enumeration to look at the multi-function flag after enumerating function 0, since part 2 will causes this chip's second function to appear.
2) poke the config space for pci197b,2363 using the same values used by the linux pci quirks mechanism.

the debug messages are not intended to be permanent.

A more general framework for PCI config space quirks would seem to be called for.

pci_boot.c is built as part of usr/src/uts/intel/pci_autoconfig/obj64/pci_autoconfig; copy it to /kernel/drv/amd64/pci_autoconfig, bootadm update-archive, and reboot.
(do this in a spare BE you can throw away if it blows up).

Also available in: Atom PDF